Skip to content

Commit ffd0652

Browse files
Strum355claude
andcommitted
build(deps): bump dependencies and migrate to ESLint 10 flat config
Bump all safe dependencies to latest major versions: - @cyclonedx/cyclonedx-library 6→10, https-proxy-agent 7→9, p-limit 4→7 - chai 4→6, mocha 10→11, sinon 15→22, sinon-chai 3→4 - eslint 8→10, typescript 5→6, which 5→7, @types/node 20→25 Migrate ESLint configuration: - Convert .eslintrc.json to eslint.config.js (flat config, required by ESLint 10) - Replace eslint-plugin-import with eslint-plugin-import-x (ESLint 10 support) - Replace eslint-plugin-editorconfig with equivalent built-in ESLint rules (plugin uses removed context.getFilename API incompatible with ESLint 10) Fix Mocha 11 breaking change: - Convert all suite().beforeAll().afterAll() chains to use suiteSetup()/suiteTeardown() inside suite callbacks (chaining API removed) Add dependabot ignore for packageurl-js (blocked on upstream purl spec issue for '+' encoding in versions, see package-url/packageurl-js#90). Closes guacsec#542 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e660b02 commit ffd0652

12 files changed

Lines changed: 169 additions & 44 deletions

‎.github/dependabot.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ updates:
99
exclude-paths:
1010
- "test/providers/tst_manifests/**"
1111
- "test/providers/provider_manifests/**"
12+
ignore:
13+
# Blocked on upstream purl spec issue for '+' encoding in versions.
14+
# See: https://github.com/package-url/packageurl-js/pull/90
15+
- dependency-name: "packageurl-js"
1216
groups:
1317
npm-dependencies:
1418
patterns:

‎eslint.config.js‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import js from "@eslint/js";
2+
import importPlugin from "eslint-plugin-import-x";
3+
import globals from "globals";
4+
5+
export default [
6+
js.configs.recommended,
7+
{
8+
plugins: {
9+
"import-x": importPlugin,
10+
},
11+
languageOptions: {
12+
ecmaVersion: 2022,
13+
sourceType: "module",
14+
globals: {
15+
...globals.node,
16+
...globals.mocha,
17+
...globals.es2021,
18+
},
19+
},
20+
rules: {
21+
...importPlugin.configs.recommended.rules,
22+
"no-unused-vars": ["error", { "caughtErrors": "none" }],
23+
"preserve-caught-error": "off",
24+
// editorconfig enforcement (replaces eslint-plugin-editorconfig)
25+
"eol-last": ["error", "always"],
26+
"indent": ["error", "tab"],
27+
"linebreak-style": ["error", "unix"],
28+
"no-trailing-spaces": "error",
29+
"unicode-bom": ["error", "never"],
30+
"curly": "warn",
31+
"eqeqeq": ["warn", "always", {"null": "never"}],
32+
"no-throw-literal": "warn",
33+
"import-x/order": ["warn", {
34+
"groups": ["builtin", "external", "internal", "parent", "sibling", "index"],
35+
"newlines-between": "always",
36+
"alphabetize": {
37+
"order": "asc",
38+
"caseInsensitive": true,
39+
},
40+
}],
41+
},
42+
settings: {
43+
"typescript": {},
44+
"import-x/resolver": {
45+
"typescript": {
46+
"extensions": [".js"],
47+
},
48+
},
49+
},
50+
},
51+
{
52+
ignores: ["index.js", "dist/**"],
53+
},
54+
];

‎test/exhort-backend-utils.test.js‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ suite('testing Select Trustify DA Backend function', () => {
1212
const testUrl = 'https://trustify-da.example.com';
1313
const testUrl2 = 'https://dev.trustify-da.example.com';
1414

15+
suiteTeardown(() => {
16+
delete process.env['TRUSTIFY_DA_BACKEND_URL'];
17+
});
18+
1519
test('When TRUSTIFY_DA_BACKEND_URL is set in environment variable, should return that value', () => {
1620
process.env['TRUSTIFY_DA_BACKEND_URL'] = testUrl;
1721
let selectedUrl = selectTrustifyDABackend({});
@@ -64,18 +68,17 @@ suite('testing Select Trustify DA Backend function', () => {
6468
};
6569
expect(() => selectTrustifyDABackend(testOpts)).to.throw('TRUSTIFY_DA_BACKEND_URL is unset');
6670
});
67-
68-
}).afterAll(() => {
69-
delete process.env['TRUSTIFY_DA_BACKEND_URL'];
7071
});
7172

7273
suite('verify token header logging', () => {
74+
suiteSetup(() => sinon.spy(console, 'log'));
75+
suiteTeardown(() => console.log.restore());
76+
7377
test('don\'t log the token header', () => {
7478
getTokenHeaders({
7579
'TRUSTIFY_DA_TOKEN': 'banana',
7680
'TRUSTIFY_DA_DEBUG': 'true'
7781
})
78-
// Should only be called once with "Headers Values to be sent to Trustify DA backend:"
7982
expect(console.log).to.be.calledOnce
8083
})
81-
}).beforeAll(() => sinon.spy(console, 'log')).afterAll(() => console.log.restore())
84+
});

‎test/providers/golang_gomodules.test.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import golangGoModules from "../../src/providers/golang_gomodules.js"
99

1010
let clock
1111
suite('testing the golang-go-modules data provider', () => {
12+
suiteSetup(() => clock = useFakeTimers(new Date('2023-08-07T00:00:00.000Z')));
13+
suiteTeardown(() => clock.restore());
1214
[
1315
{name: 'go.mod', expected: true},
1416
{name: 'some_other.file', expected: false}
@@ -81,6 +83,6 @@ suite('testing the golang-go-modules data provider', () => {
8183
}).timeout(process.env.GITHUB_ACTIONS ? 30000 : 10000)
8284

8385
})
84-
}).beforeAll(() => clock = useFakeTimers(new Date('2023-08-07T00:00:00.000Z'))).afterAll(()=> clock.restore());
86+
});
8587

8688

‎test/providers/java_gradle_groovy.test.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ function getStubbedResponse(args, dependencyTreeTextContent, gradleProperties) {
2727
}
2828

2929
suite('testing the java-gradle-groovy data provider', () => {
30+
suiteSetup(() => clock = useFakeTimers(new Date('2023-08-07T00:00:00.000Z')));
31+
suiteTeardown(() => clock.restore());
3032

3133
[
3234
{ name: 'build.gradle', expected: true },
@@ -100,5 +102,5 @@ suite('testing the java-gradle-groovy data provider', () => {
100102
throws(() => provider.provideComponent(`test/providers/tst_manifests/gradle/${testCase}/build.gradle`, {}))
101103
})
102104
})
103-
}).beforeAll(() => clock = useFakeTimers(new Date('2023-08-07T00:00:00.000Z'))).afterAll(() => { clock.restore() });
105+
});
104106

‎test/providers/java_gradle_kotlin.test.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ function getStubbedResponse(args, dependencyTreeTextContent, gradleProperties) {
2727
}
2828

2929
suite('testing the java-gradle-kotlin data provider', () => {
30+
suiteSetup(() => clock = useFakeTimers(new Date('2023-08-07T00:00:00.000Z')));
31+
suiteTeardown(() => clock.restore());
3032

3133
[
3234
{ name: 'build.gradle.kts', expected: true },
@@ -100,5 +102,5 @@ suite('testing the java-gradle-kotlin data provider', () => {
100102
throws(() => provider.provideComponent(`test/providers/tst_manifests/gradle/${testCase}/build.gradle`, {}))
101103
})
102104
})
103-
}).beforeAll(() => clock = useFakeTimers(new Date('2023-08-07T00:00:00.000Z'))).afterAll(() => { clock.restore() });
105+
});
104106

‎test/providers/java_maven.test.js‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ async function createMockProvider(testPath) {
4848

4949
const mvnPath = await which('mvn');
5050
suite('testing the java-maven data provider', async () => {
51+
suiteSetup(() => clock = useFakeTimers(new Date('2023-08-07T00:00:00.000Z')));
52+
suiteTeardown(() => clock.restore());
5153

5254
[
5355
{name: 'pom.xml', expected: true},
@@ -126,9 +128,11 @@ suite('testing the java-maven data provider', async () => {
126128
// these test cases takes ~1400-2000 ms each pr >10000 in CI (for the first test-case)
127129

128130
})
129-
}).beforeAll(() => clock = useFakeTimers(new Date('2023-08-07T00:00:00.000Z'))).afterAll(()=> {clock.restore()});
131+
});
130132

131133
suite('testing the java-maven data provider with modules', () => {
134+
suiteSetup(() => clock = useFakeTimers(new Date('2023-08-07T00:00:00.000Z')));
135+
suiteTeardown(() => clock.restore());
132136
[
133137
"pom_with_one_module",
134138
"pom_with_multiple_modules"
@@ -155,9 +159,11 @@ suite('testing the java-maven data provider with modules', () => {
155159
// these test cases takes ~1400-2000 ms each pr >10000 in CI (for the first test-case)
156160

157161
})
158-
}).beforeAll(() => clock = useFakeTimers(new Date('2023-08-07T00:00:00.000Z'))).afterAll(()=> {clock.restore()});
162+
});
159163

160164
suite('testing the java-maven version parsing in getDependencies', () => {
165+
suiteSetup(() => clock = useFakeTimers(new Date('2023-08-07T00:00:00.000Z')));
166+
suiteTeardown(() => clock.restore());
161167
test('verify version parsing works correctly', async () => {
162168
const testCase = 'pom_deps_with_ignore_version_from_property';
163169
const javaMvnProvider = await createMockProvider(`test/providers/tst_manifests/maven/${testCase}`);
@@ -174,4 +180,4 @@ suite('testing the java-maven version parsing in getDependencies', () => {
174180
expect(bouncyCastleDependency).to.exist;
175181
expect(bouncyCastleDependency.ref).to.equal('pkg:maven/org.bouncycastle/bcprov-jdk18on@1.80');
176182
});
177-
}).beforeAll(() => clock = useFakeTimers(new Date('2023-08-07T00:00:00.000Z'))).afterAll(()=> {clock.restore()});
183+
});

‎test/providers/javascript.test.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ async function createMockProvider(providerName, listingOutput) {
5454
}
5555

5656
suite('testing the javascript-npm data provider', async () => {
57+
suiteSetup(() => clock = useFakeTimers(new Date('2023-08-07T00:00:00.000Z')));
58+
suiteTeardown(() => clock.restore());
5759
[
5860
{ name: 'npm/with_lock_file', validation: true },
5961
{ name: 'npm/without_lock_file', validation: false },
@@ -371,4 +373,4 @@ suite('testing the javascript-npm data provider', async () => {
371373
.to.throw('package.json requires a lock file')
372374
})
373375

374-
}).beforeAll(() => clock = useFakeTimers(new Date('2023-08-07T00:00:00.000Z'))).afterAll(() => clock.restore());
376+
});

‎test/providers/oci_images.test.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { generateImageSBOM, parseImageRef } from '../../src/oci_image/utils.js';
77

88
let clock;
99
suite('testing the OCI image data provider', () => {
10+
suiteSetup(() => clock = useFakeTimers(new Date('2023-08-07T00:00:00.000Z')));
11+
suiteTeardown(() => clock.restore());
1012
[
1113
"httpd@sha256:4b5cb7697fea2aa6d398504c381b693a54ae9ad5e6317fcdbb7a2d9b8c3b1364",
1214
"httpd:2.4.49",
@@ -36,4 +38,4 @@ suite('testing the OCI image data provider', () => {
3638
}).timeout(10000)
3739
})
3840

39-
}).beforeAll(() => clock = useFakeTimers(new Date('2023-08-07T00:00:00.000Z'))).afterAll(() => clock.restore());
41+
});

‎test/providers/python_pip.test.js‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ async function sharedStackAnalysisTestFlow(testCase, usePipDepTreeUtility) {
4949
}
5050

5151
suite('testing the python-pip data provider', () => {
52+
suiteSetup(() => clock = useFakeTimers(new Date('2023-10-01T00:00:00.000Z')));
53+
suiteTeardown(() => clock.restore());
5254
[
5355
{name: 'requirements.txt', expected: true},
5456
{name: 'some_other.file', expected: false}
@@ -84,9 +86,11 @@ suite('testing the python-pip data provider', () => {
8486
}).timeout(process.env.GITHUB_ACTIONS ? 15000 : 10000)
8587
});
8688

87-
}).beforeAll(() => clock = useFakeTimers(new Date('2023-10-01T00:00:00.000Z'))).afterAll(()=> clock.restore());
89+
});
8890

8991
suite('testing the python-pip data provider with virtual environment', () => {
92+
suiteSetup(() => clock = useFakeTimers(new Date('2023-10-01T00:00:00.000Z')));
93+
suiteTeardown(() => clock.restore());
9094
[
9195
"pip_requirements_virtual_env_txt_no_ignore",
9296
"pip_requirements_virtual_env_with_ignore"
@@ -115,9 +119,11 @@ suite('testing the python-pip data provider with virtual environment', () => {
115119
}).timeout(process.env.GITHUB_ACTIONS ? 60000 : 30000)
116120
})
117121

118-
}).beforeAll(() => {clock = useFakeTimers(new Date('2023-10-01T00:00:00.000Z'))}).afterAll(()=> clock.restore());
122+
});
119123

120124
suite('testing python-pip PEP 508 marker handling', () => {
125+
suiteSetup(() => clock = useFakeTimers(new Date('2023-10-01T00:00:00.000Z')));
126+
suiteTeardown(() => clock.restore());
121127
const markerTestCase = 'pip_requirements_txt_marker_skip'
122128

123129
/** Verify that packages with environment markers (PEP 508) that are not installed
@@ -153,9 +159,11 @@ suite('testing python-pip PEP 508 marker handling', () => {
153159
}
154160
}).timeout(10000)
155161

156-
}).beforeAll(() => clock = useFakeTimers(new Date('2023-10-01T00:00:00.000Z'))).afterAll(() => clock.restore());
162+
});
157163

158164
suite('testing python-pip SHA-256 hash extraction via pip inspect', () => {
165+
suiteSetup(() => clock = useFakeTimers(new Date('2023-10-01T00:00:00.000Z')));
166+
suiteTeardown(() => clock.restore());
159167
const hashTestCase = 'pip_requirements_txt_with_hashes'
160168

161169
const pipFreezeOutput = 'certifi==2023.7.22\nsix==1.16.0\n'
@@ -276,9 +284,11 @@ suite('testing python-pip SHA-256 hash extraction via pip inspect', () => {
276284
}
277285
}).timeout(10000)
278286

279-
}).beforeAll(() => clock = useFakeTimers(new Date('2023-10-01T00:00:00.000Z'))).afterAll(() => clock.restore());
287+
});
280288

281289
suite('testing python-pip SHA-256 hashes with real pip inspect', () => {
290+
suiteSetup(() => clock = useFakeTimers(new Date('2023-10-01T00:00:00.000Z')));
291+
suiteTeardown(() => clock.restore());
282292
const testCase = 'pip_requirements_txt_with_hashes'
283293

284294
/** Verifies SBOM components include SHA-256 hashes from real pip inspect. */
@@ -302,4 +312,4 @@ suite('testing python-pip SHA-256 hashes with real pip inspect', () => {
302312
}
303313
}).timeout(process.env.GITHUB_ACTIONS ? 30000 : 10000)
304314

305-
}).beforeAll(() => clock = useFakeTimers(new Date('2023-10-01T00:00:00.000Z'))).afterAll(() => clock.restore());
315+
});

0 commit comments

Comments
 (0)