Skip to content
This repository was archived by the owner on Jul 8, 2025. It is now read-only.

Commit e36d613

Browse files
committed
feat: implement OCI image analysis natively instead of via java API adapter
1 parent b98d524 commit e36d613

File tree

4 files changed

+35
-35
lines changed

4 files changed

+35
-35
lines changed
Binary file not shown.

package-lock.json

Lines changed: 27 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
],
2626
"dependencies": {
2727
"@trustification/exhort-api-spec": "^1.0.13",
28-
"@trustification/exhort-javascript-api": "^0.1.1-ea.71",
28+
"@trustification/exhort-javascript-api": "^0.1.1-ea.73",
2929
"@xml-tools/ast": "^5.0.5",
3030
"@xml-tools/parser": "^1.0.11",
3131
"json-to-ast": "^2.1.0",

src/imageAnalysis/analysis.ts

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* ------------------------------------------------------------------------------------------ */
55
'use strict';
66

7-
import { execSync } from 'child_process';
7+
import exhort from '@trustification/exhort-javascript-api';
88

99
import { connection } from '../server';
1010
import { globalConfig } from '../config';
@@ -219,36 +219,13 @@ interface IOptions {
219219
* @param options - The options for running image analysis.
220220
* @returns A Promise resolving to the analysis response.
221221
*/
222-
function imageAnalysisService(images: IImage[], options: IOptions): Promise<any> {
223-
return new Promise<any>((resolve, reject) => {
224-
const jarPath = `${__dirname}/../javaApiAdapter/exhort-java-api-adapter-1.0-SNAPSHOT-jar-with-dependencies.jar`;
225-
const reportType = 'json';
226-
let parameters = '';
227-
let properties = '';
228-
229-
images.forEach(image => {
230-
if (image.platform) {
231-
parameters += ` ${image.name.value}^^${image.platform}`;
232-
} else {
233-
parameters += ` ${image.name.value}`;
234-
}
235-
});
236-
237-
for (const setting in options) {
238-
if (options[setting]) {
239-
properties += ` -D${setting}=${options[setting]}`;
240-
}
222+
async function imageAnalysisService(images: IImage[], options: IOptions): Promise<any> {
223+
return await exhort.imageAnalysis(images.map(img => {
224+
if (img.platform) {
225+
return `${img.name.value}^^${img.platform}`;
241226
}
242-
243-
try {
244-
const result = execSync(`java${properties} -jar ${jarPath} ${reportType}${parameters}`, {
245-
maxBuffer: 1000 * 1000 * 10, // 10 MB
246-
});
247-
resolve(JSON.parse(result.toString()));
248-
} catch (error) {
249-
reject(error);
250-
}
251-
});
227+
return img.name.value;
228+
}), true, options);
252229
}
253230

254231
/**

0 commit comments

Comments
 (0)