Skip to content

Commit 607480b

Browse files
committed
fix: bump to v10
2 parents 3f5a419 + b814413 commit 607480b

File tree

22 files changed

+5084
-2521
lines changed

22 files changed

+5084
-2521
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 29 deletions
This file was deleted.

.snyk

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,6 @@
22
version: v1.25.0
33
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
44
ignore:
5-
SNYK-JS-TAR-15307072:
6-
- 'snyk-nodejs-lockfile-parser > @yarnpkg/core > tar':
7-
reason: 'Indirect dependency from snyk-nodejs-lockfile-parser, waiting for upstream fix'
8-
expires: 2026-05-06T00:00:00.000Z
9-
SNYK-JS-TAR-15416075:
10-
- 'snyk-nodejs-lockfile-parser > @yarnpkg/core > tar':
11-
reason: 'Indirect dependency from snyk-nodejs-lockfile-parser, waiting for upstream fix'
12-
expires: 2026-05-06T00:00:00.000Z
13-
SNYK-JS-TAR-15456201:
14-
- 'snyk-nodejs-lockfile-parser > @yarnpkg/core > tar':
15-
reason: 'Indirect dependency from snyk-nodejs-lockfile-parser, waiting for upstream fix'
16-
expires: 2026-05-06T00:00:00.000Z
175
SNYK-JS-LODASH-15869625:
186
- '*':
197
reason: 'Indirect dependency, waiting for upstream fix'

components/common.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ schemas:
1717
enum:
1818
- autoDetectedUserInstructions
1919
- binaries
20+
- baseRuntimes
2021
- depGraph
2122
- dockerfileAnalysis
2223
- dockerLayers

eslint.config.mjs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import eslint from "@eslint/js";
2+
import tseslint from "typescript-eslint";
3+
import eslintConfigPrettier from "eslint-config-prettier/flat";
4+
5+
export default tseslint.config(
6+
{
7+
ignores: ["dist/", "node_modules/"],
8+
},
9+
eslint.configs.recommended,
10+
...tseslint.configs.recommended,
11+
eslintConfigPrettier,
12+
{
13+
rules: {
14+
"no-shadow": "off",
15+
"@typescript-eslint/no-shadow": "off",
16+
"@typescript-eslint/naming-convention": "off",
17+
"no-bitwise": "off",
18+
"max-classes-per-file": "off",
19+
"no-console": "off",
20+
"@typescript-eslint/no-explicit-any": "off",
21+
"no-case-declarations": "off",
22+
"no-useless-escape": "off",
23+
"no-prototype-builtins": "off",
24+
"@typescript-eslint/no-require-imports": "off",
25+
"@typescript-eslint/no-namespace": "off",
26+
"no-control-regex": "off",
27+
// New in ESLint v10 recommended — not part of the pre-migration rule set
28+
"preserve-caught-error": "off",
29+
"no-useless-assignment": "off",
30+
31+
// New in typescript-eslint v8 recommended — not part of the pre-migration rule set
32+
"@typescript-eslint/no-empty-object-type": "off",
33+
"@typescript-eslint/no-unused-expressions": "off",
34+
35+
"@typescript-eslint/no-unused-vars": [
36+
"error",
37+
{
38+
argsIgnorePattern: "^_",
39+
varsIgnorePattern: "^_",
40+
// v8 changed the default from "none" to "all"; restore old behaviour
41+
caughtErrors: "none",
42+
},
43+
],
44+
},
45+
},
46+
);

lib/analyzer/applications/node.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ async function depGraphFromNodeModules(
136136
}
137137

138138
const depGraph = await legacy.depTreeToGraph(
139-
pkgTree,
139+
pkgTree as any,
140140
pkgTree.type || "npm",
141141
);
142142

@@ -417,7 +417,7 @@ function stripUndefinedLabels(
417417
parserResult: lockFileParser.PkgTree,
418418
): lockFileParser.PkgTree {
419419
const optionalLabels = parserResult.labels;
420-
const mandatoryLabels: Record<string, string> = {};
420+
const mandatoryLabels: Record<string, any> = {};
421421
if (optionalLabels) {
422422
for (const currentLabelName of Object.keys(optionalLabels)) {
423423
if (optionalLabels[currentLabelName] !== undefined) {
@@ -428,7 +428,7 @@ function stripUndefinedLabels(
428428
const parserResultWithProperLabels = Object.assign({}, parserResult, {
429429
labels: mandatoryLabels,
430430
});
431-
return parserResultWithProperLabels;
431+
return parserResultWithProperLabels as lockFileParser.PkgTree;
432432
}
433433

434434
async function buildDepGraph(
@@ -513,7 +513,10 @@ async function buildDepGraphFromDepTree(
513513
// Don't provide a default manifest file name, prefer the parser to infer it.
514514
);
515515
const strippedLabelsParserResult = stripUndefinedLabels(parserResult);
516-
return await legacy.depTreeToGraph(strippedLabelsParserResult, lockfileType);
516+
return await legacy.depTreeToGraph(
517+
strippedLabelsParserResult as any,
518+
lockfileType,
519+
);
517520
}
518521

519522
export function getLockFileVersion(
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ExtractedLayers } from "../../extractor/types";
2+
import { BaseRuntime } from "../../facts";
3+
import { getJavaRuntimeReleaseContent } from "../../inputs/base-runtimes/static";
4+
import { parseJavaRuntimeRelease } from "./parser";
5+
6+
export function detectJavaRuntime(
7+
extractedLayers: ExtractedLayers,
8+
): BaseRuntime | null {
9+
const releaseContent = getJavaRuntimeReleaseContent(extractedLayers);
10+
return releaseContent ? parseJavaRuntimeRelease(releaseContent) : null;
11+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { BaseRuntime } from "../../facts";
2+
3+
const VALID_VERSION_PATTERN =
4+
/^(?!.*\.\.)[0-9]+(?:[._+a-zA-Z0-9-]*[a-zA-Z0-9])?$/;
5+
6+
const regex = /^\s*JAVA_VERSION\s*=\s*(?:(["'])(.*?)\1|([^#\r\n]+))/gm;
7+
8+
function isValidJavaVersion(version: string): boolean {
9+
if (!version || version.length === 0) {
10+
return false;
11+
}
12+
return VALID_VERSION_PATTERN.test(version);
13+
}
14+
15+
export function parseJavaRuntimeRelease(content: string): BaseRuntime | null {
16+
if (!content || content.trim().length === 0) {
17+
return null;
18+
}
19+
try {
20+
const matches = [...content.matchAll(regex)];
21+
22+
if (matches.length !== 1) {
23+
return null;
24+
}
25+
const version = (matches[0][2] || matches[0][3] || "").trim();
26+
27+
if (!isValidJavaVersion(version)) {
28+
return null;
29+
}
30+
return { type: "java", version };
31+
} catch (error) {
32+
return null;
33+
}
34+
}

lib/analyzer/static-analyzer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
getDpkgFileContentAction,
1616
getExtFileContentAction,
1717
} from "../inputs/apt/static";
18+
import { getJavaRuntimeReleaseAction } from "../inputs/base-runtimes/static";
1819
import {
1920
getBinariesHashes,
2021
getNodeBinariesFileContentAction,
@@ -67,6 +68,7 @@ import { jarFilesToScannedResults } from "./applications/java";
6768
import { pipFilesToScannedProjects } from "./applications/python";
6869
import { getApplicationFiles } from "./applications/runtime-common";
6970
import { AppDepsScanResultWithoutTarget } from "./applications/types";
71+
import { detectJavaRuntime } from "./base-runtimes";
7072
import * as osReleaseDetector from "./os-release";
7173
import { analyze as apkAnalyze } from "./package-managers/apk";
7274
import {
@@ -105,6 +107,7 @@ export async function analyze(
105107
...getOsReleaseActions,
106108
getNodeBinariesFileContentAction,
107109
getOpenJDKBinariesFileContentAction,
110+
getJavaRuntimeReleaseAction,
108111
getDpkgPackageFileContentAction,
109112
getRedHatRepositoriesContentAction,
110113
];
@@ -233,6 +236,8 @@ export async function analyze(
233236
}
234237

235238
const binaries = getBinariesHashes(extractedLayers);
239+
const javaRuntime = detectJavaRuntime(extractedLayers);
240+
const baseRuntimes = javaRuntime ? [javaRuntime] : undefined;
236241

237242
const applicationDependenciesScanResults: AppDepsScanResultWithoutTarget[] =
238243
[];
@@ -309,6 +314,7 @@ export async function analyze(
309314
platform,
310315
results,
311316
binaries,
317+
baseRuntimes,
312318
imageLayers: manifestLayers,
313319
rootFsLayers,
314320
applicationDependenciesScanResults,

lib/analyzer/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ImageName } from "../extractor/image";
2+
import { BaseRuntime } from "../facts";
23
import { AutoDetectedUserInstructions, ManifestFile } from "../types";
34
import {
45
AppDepsScanResultWithoutTarget,
@@ -75,6 +76,7 @@ export interface StaticAnalysis {
7576
osRelease: OSRelease;
7677
results: ImageAnalysis[];
7778
binaries: string[];
79+
baseRuntimes?: BaseRuntime[];
7880
imageLayers: string[];
7981
rootFsLayers?: string[];
8082
autoDetectedUserInstructions?: AutoDetectedUserInstructions;

0 commit comments

Comments
 (0)