|
18 | 18 |
|
19 | 19 | import static io.github.guacsec.trustifyda.impl.ExhortApi.debugLoggingIsNeeded; |
20 | 20 |
|
21 | | -import com.github.packageurl.MalformedPackageURLException; |
22 | 21 | import com.github.packageurl.PackageURL; |
23 | 22 | import io.github.guacsec.trustifyda.Api; |
24 | 23 | import io.github.guacsec.trustifyda.Provider; |
|
40 | 39 | import java.util.List; |
41 | 40 | import java.util.Map; |
42 | 41 | import java.util.Objects; |
43 | | -import java.util.TreeMap; |
44 | 42 | import java.util.logging.Level; |
45 | 43 | import java.util.logging.Logger; |
46 | 44 | import java.util.stream.Collectors; |
@@ -431,78 +429,6 @@ private List<String> buildMvnCommandArgs(String... baseArgs) { |
431 | 429 | return args; |
432 | 430 | } |
433 | 431 |
|
434 | | - // NOTE if we want to include "scope" tags in ignore, |
435 | | - // add property here and a case in the start-element-switch in the getIgnored method |
436 | | - |
437 | | - /** Aggregator class for aggregating Dependency data over stream iterations, * */ |
438 | | - private static final class DependencyAggregator { |
439 | | - private String scope = "*"; |
440 | | - private String groupId; |
441 | | - private String artifactId; |
442 | | - private String version; |
443 | | - boolean ignored = false; |
444 | | - |
445 | | - /** |
446 | | - * Get the string representation of the dependency to use as excludes |
447 | | - * |
448 | | - * @return an exclude string for the dependency:tree plugin, i.e. group-id:artifact-id:*:version |
449 | | - */ |
450 | | - @Override |
451 | | - public String toString() { |
452 | | - // NOTE if you add scope, don't forget to replace the * with its value |
453 | | - return String.format("%s:%s:%s:%s", groupId, artifactId, scope, version); |
454 | | - } |
455 | | - |
456 | | - public boolean isValid() { |
457 | | - return Objects.nonNull(groupId) && Objects.nonNull(artifactId) && Objects.nonNull(version); |
458 | | - } |
459 | | - |
460 | | - public boolean isTestDependency() { |
461 | | - return scope.trim().equals("test"); |
462 | | - } |
463 | | - |
464 | | - public PackageURL toPurl() { |
465 | | - try { |
466 | | - return new PackageURL( |
467 | | - Type.MAVEN.getType(), |
468 | | - groupId, |
469 | | - artifactId, |
470 | | - version, |
471 | | - this.scope.equals("*") ? null : new TreeMap<>(Map.of("scope", this.scope)), |
472 | | - null); |
473 | | - } catch (MalformedPackageURLException e) { |
474 | | - throw new IllegalArgumentException("Unable to parse PackageURL", e); |
475 | | - } |
476 | | - } |
477 | | - |
478 | | - /** Creates a PackageURL without version for coordinate-based matching. */ |
479 | | - public PackageURL toPurlWithoutVersion() { |
480 | | - try { |
481 | | - return new PackageURL(Type.MAVEN.getType(), groupId, artifactId, null, null, null); |
482 | | - } catch (MalformedPackageURLException e) { |
483 | | - throw new IllegalArgumentException("Unable to parse PackageURL", e); |
484 | | - } |
485 | | - } |
486 | | - |
487 | | - @Override |
488 | | - public boolean equals(Object o) { |
489 | | - if (this == o) return true; |
490 | | - if (!(o instanceof DependencyAggregator)) return false; |
491 | | - var that = (DependencyAggregator) o; |
492 | | - // NOTE we do not compare the ignored field |
493 | | - // This is required for comparing pom.xml with effective_pom.xml as the latter doesn't |
494 | | - // contain comments indicating ignore |
495 | | - return Objects.equals(this.groupId, that.groupId) |
496 | | - && Objects.equals(this.artifactId, that.artifactId) |
497 | | - && Objects.equals(this.version, that.version); |
498 | | - } |
499 | | - |
500 | | - @Override |
501 | | - public int hashCode() { |
502 | | - return Objects.hash(groupId, artifactId, version); |
503 | | - } |
504 | | - } |
505 | | - |
506 | 432 | private String selectMvnRuntime(final Path manifestPath) { |
507 | 433 | boolean preferWrapper = Operations.getWrapperPreference(MVN); |
508 | 434 | if (preferWrapper && manifestPath != null) { |
|
0 commit comments