Skip to content

Commit 5736c58

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/tar-fs-2.1.2
2 parents 5dc9268 + 973a8cf commit 5736c58

File tree

7 files changed

+107
-16
lines changed

7 files changed

+107
-16
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Managed and Maintained by:
2+
3+
* @advanced-security/advanced-security-dependency-graph

dist/index.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,19 @@ class MavenDependencyGraph {
4747
const artifact = this.packageUrlToArtifact[depPackage.packageURL.toString()];
4848
let scope = getDependencyScopeForMavenScope(artifact.scopes);
4949
manifest.addDirectDependency(depPackage, scope);
50-
function addTransitiveDeps(dependencies) {
50+
function addTransitiveDeps(dependencies, seen = new Set()) {
5151
if (dependencies) {
5252
dependencies.forEach(transitiveDep => {
53-
const transitiveDepArtifact = packageUrlToArtifact[transitiveDep.packageURL.toString()];
53+
let purl = transitiveDep.packageURL.toString();
54+
if (seen.has(purl)) {
55+
// we're in a cycle! skip this one.
56+
return;
57+
}
58+
const transitiveDepArtifact = packageUrlToArtifact[purl];
5459
const transitiveDepScope = getDependencyScopeForMavenScope(transitiveDepArtifact.scopes);
5560
manifest.addIndirectDependency(transitiveDep, transitiveDepScope);
56-
addTransitiveDeps(transitiveDep.dependencies);
61+
seen.add(purl);
62+
addTransitiveDeps(transitiveDep.dependencies, seen);
5763
});
5864
}
5965
}
@@ -484,7 +490,7 @@ const depgraph_1 = __nccwpck_require__(8047);
484490
const maven_runner_1 = __nccwpck_require__(7433);
485491
const file_utils_1 = __nccwpck_require__(799);
486492
const packageData = __nccwpck_require__(2876);
487-
const DEPGRAPH_MAVEN_PLUGIN_VERSION = '4.0.2';
493+
const DEPGRAPH_MAVEN_PLUGIN_VERSION = '4.0.3';
488494
function generateSnapshot(directory, mvnConfig, snapshotConfig) {
489495
return __awaiter(this, void 0, void 0, function* () {
490496
var _a, _b;
@@ -512,11 +518,11 @@ function generateSnapshot(directory, mvnConfig, snapshotConfig) {
512518
snapshot.job.correlator = (snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.correlator)
513519
? snapshotConfig.correlator
514520
: (_b = snapshot.job) === null || _b === void 0 ? void 0 : _b.correlator;
515-
const specifiedRef = getNonEmtptyValue(snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.ref);
521+
const specifiedRef = getNonEmptyValue(snapshotConfig === null || snapshotConfig === void 0 ? void 0 : snapshotConfig.ref);
516522
if (specifiedRef) {
517523
snapshot.ref = specifiedRef;
518524
}
519-
const specifiedSha = getNonEmtptyValue(snapshot === null || snapshot === void 0 ? void 0 : snapshot.sha);
525+
const specifiedSha = getNonEmptyValue(snapshot === null || snapshot === void 0 ? void 0 : snapshot.sha);
520526
if (specifiedSha) {
521527
snapshot.sha = specifiedSha;
522528
}
@@ -616,7 +622,7 @@ function getRepositoryRelativePath(file) {
616622
core.debug(`Snapshot relative file = ${result}`);
617623
return result;
618624
}
619-
function getNonEmtptyValue(str) {
625+
function getNonEmptyValue(str) {
620626
if (str) {
621627
const trimmed = str.trim();
622628
if (trimmed.length > 0) {
@@ -33295,7 +33301,7 @@ exports.submitSnapshot = L;
3329533301
/***/ ((module) => {
3329633302

3329733303
"use strict";
33298-
module.exports = JSON.parse('{"name":"maven-dependency-submission-action","version":"4.1.1","description":"Submit Maven dependencies to GitHub dependency submission API","main":"index.js","scripts":{"base-build":"npm ci && tsc","build":"npm run base-build && npm exec -- @vercel/ncc build --source-map lib/src/index.js","build-exe":"npm run build && pkg package.json --compress Gzip","test":"vitest --run"},"repository":{"type":"git","url":"git+https://github.com/advanced-security/maven-dependency-submission-action.git"},"keywords":[],"author":"GitHub, Inc","license":"MIT","bugs":{"url":"https://github.com/advanced-security/maven-dependency-submission-action/issues"},"homepage":"https://github.com/advanced-security/maven-dependency-submission-action","dependencies":{"@actions/core":"^1.10.1","@actions/exec":"^1.1.1","@github/dependency-submission-toolkit":"^2.0.0","commander":"^12.0.0","packageurl-js":"^1.2.0"},"devDependencies":{"@types/chai":"^4.3.1","@vercel/ncc":"^0.38.1","chai":"^4.3.6","@yao-pkg/pkg":"^5.11.5","ts-node":"^10.9.2","typescript":"^5.3.3","vitest":"^1.2.1"},"bin":{"cli":"lib/src/executable/cli.js"},"pkg":{"targets":["node20-linux-x64","node20-win-x64","node20-macos-x64"],"assets":["package.json"],"publicPackages":"*","outputPath":"cli"}}');
33304+
module.exports = JSON.parse('{"name":"maven-dependency-submission-action","version":"4.1.2","description":"Submit Maven dependencies to GitHub dependency submission API","main":"index.js","scripts":{"base-build":"npm ci && tsc","build":"npm run base-build && npm exec -- @vercel/ncc build --source-map lib/src/index.js","build-exe":"npm run build && pkg package.json --compress Gzip","test":"vitest --run"},"repository":{"type":"git","url":"git+https://github.com/advanced-security/maven-dependency-submission-action.git"},"keywords":[],"author":"GitHub, Inc","license":"MIT","bugs":{"url":"https://github.com/advanced-security/maven-dependency-submission-action/issues"},"homepage":"https://github.com/advanced-security/maven-dependency-submission-action","dependencies":{"@actions/core":"^1.10.1","@actions/exec":"^1.1.1","@github/dependency-submission-toolkit":"^2.0.0","commander":"^12.0.0","packageurl-js":"^1.2.0"},"devDependencies":{"@types/chai":"^4.3.1","@vercel/ncc":"^0.38.1","chai":"^4.3.6","@yao-pkg/pkg":"^5.11.5","ts-node":"^10.9.2","typescript":"^5.3.3","vitest":"^1.6.1"},"bin":{"cli":"lib/src/executable/cli.js"},"pkg":{"targets":["node20-linux-x64","node20-win-x64","node20-macos-x64"],"assets":["package.json"],"publicPackages":"*","outputPath":"cli"}}');
3329933305

3330033306
/***/ })
3330133307

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/depgraph.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,25 @@ describe('depgraph', () => {
116116
});
117117
});
118118

119+
describe('cycle-tree', () => {
120+
let depGraph;
121+
beforeAll(() => {
122+
depGraph = parseDependencyJson(getTestDataFile("cycle-tree"));
123+
});
124+
125+
it('should parse out the top level dependencies', () => {
126+
const mavenDependencies = new MavenDependencyGraph(depGraph);
127+
expect(mavenDependencies.getPackageCount()).to.equal(3);
128+
});
129+
130+
it('should be able to generate a manifest despite having a cycle', () => {
131+
const mavenDependencies = new MavenDependencyGraph(depGraph);
132+
const manifest = mavenDependencies.createManifest();
133+
134+
expect(manifest.name).to.equal('hadoop-main');
135+
expect(manifest.countDependencies()).to.equal(2);
136+
})
137+
});
119138

120139
describe('bs-parent-dep-tree', () => {
121140

src/depgraph.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,19 @@ export class MavenDependencyGraph {
8585
let scope = getDependencyScopeForMavenScope(artifact.scopes);
8686
manifest.addDirectDependency(depPackage, scope);
8787

88-
function addTransitiveDeps(dependencies) {
88+
function addTransitiveDeps(dependencies, seen: Set<string> = new Set()) {
8989
if (dependencies) {
9090
dependencies.forEach(transitiveDep => {
91-
const transitiveDepArtifact = packageUrlToArtifact[transitiveDep.packageURL.toString()];
91+
let purl = transitiveDep.packageURL.toString();
92+
if (seen.has(purl)) {
93+
// we're in a cycle! skip this one.
94+
return;
95+
}
96+
const transitiveDepArtifact = packageUrlToArtifact[purl];
9297
const transitiveDepScope = getDependencyScopeForMavenScope(transitiveDepArtifact.scopes);
9398
manifest.addIndirectDependency(transitiveDep, transitiveDepScope);
94-
addTransitiveDeps(transitiveDep.dependencies);
99+
seen.add(purl);
100+
addTransitiveDeps(transitiveDep.dependencies, seen);
95101
});
96102
}
97103
}

src/snapshot-generator.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { MavenRunner } from './maven-runner';
77
import { loadFileContents } from './utils/file-utils';
88

99
const packageData = require('../package.json');
10-
const DEPGRAPH_MAVEN_PLUGIN_VERSION = '4.0.2';
10+
const DEPGRAPH_MAVEN_PLUGIN_VERSION = '4.0.3';
1111

1212
export type MavenConfiguration = {
1313
ignoreMavenWrapper?: boolean;
@@ -58,12 +58,12 @@ export async function generateSnapshot(directory: string, mvnConfig?: MavenConfi
5858
? snapshotConfig.correlator
5959
: snapshot.job?.correlator;
6060

61-
const specifiedRef = getNonEmtptyValue(snapshotConfig?.ref);
61+
const specifiedRef = getNonEmptyValue(snapshotConfig?.ref);
6262
if (specifiedRef) {
6363
snapshot.ref = specifiedRef;
6464
}
6565

66-
const specifiedSha = getNonEmtptyValue(snapshot?.sha);
66+
const specifiedSha = getNonEmptyValue(snapshot?.sha);
6767
if (specifiedSha) {
6868
snapshot.sha = specifiedSha;
6969
}
@@ -173,7 +173,7 @@ function getRepositoryRelativePath(file) {
173173
return result;
174174
}
175175

176-
function getNonEmtptyValue(str?: string) {
176+
function getNonEmptyValue(str?: string) {
177177
if (str) {
178178
const trimmed = str.trim();
179179
if (trimmed.length > 0) {
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"graphName" : "hadoop-main",
3+
"artifacts" : [ {
4+
"id" : "org.apache.hadoop:hadoop-annotations:jar:compile",
5+
"numericId" : 1,
6+
"groupId" : "org.apache.hadoop",
7+
"artifactId" : "hadoop-annotations",
8+
"version" : "3.5.0-SNAPSHOT",
9+
"optional" : false,
10+
"scopes" : [ "compile" ],
11+
"types" : [ "jar" ]
12+
}, {
13+
"id" : "jdiff:jdiff:jar:provided",
14+
"numericId" : 2,
15+
"groupId" : "jdiff",
16+
"artifactId" : "jdiff",
17+
"version" : "1.0.9",
18+
"optional" : false,
19+
"scopes" : [ "provided" ],
20+
"types" : [ "jar" ]
21+
}, {
22+
"id" : "org.apache.hadoop:hadoop-project-dist:pom:compile",
23+
"numericId" : 3,
24+
"groupId" : "org.apache.hadoop",
25+
"artifactId" : "hadoop-project-dist",
26+
"version" : "3.5.0-SNAPSHOT",
27+
"optional" : false,
28+
"scopes" : [ "compile" ],
29+
"types" : [ "pom" ]
30+
} ],
31+
"dependencies" : [ {
32+
"from" : "org.apache.hadoop:hadoop-annotations:jar:compile",
33+
"to" : "jdiff:jdiff:jar:provided",
34+
"numericFrom" : 1,
35+
"numericTo" : 2,
36+
"resolution" : "INCLUDED"
37+
}, {
38+
"from" : "org.apache.hadoop:hadoop-annotations:jar:compile",
39+
"to" : "jdiff:jdiff:jar:provided",
40+
"numericFrom" : 1,
41+
"numericTo" : 3,
42+
"resolution" : "INCLUDED"
43+
}, {
44+
"from" : "jdiff:jdiff:jar:provided",
45+
"to" : "org.apache.hadoop:hadoop-project-dist:pom:compile",
46+
"numericFrom" : 2,
47+
"numericTo" : 3,
48+
"resolution" : "INCLUDED"
49+
}, {
50+
"from" : "org.apache.hadoop:hadoop-project-dist:pom:compile",
51+
"to" : "jdiff:jdiff:jar:provided",
52+
"numericFrom" : 3,
53+
"numericTo" : 2,
54+
"resolution" : "INCLUDED"
55+
}
56+
]
57+
}

0 commit comments

Comments
 (0)