Skip to content

Commit 4db2ece

Browse files
committed
feat: accept and forward OS Release name and version
- the return format from the analyzer has changed - not marking these changes as breaking as we're not stable yet and the API/contracts are not formalised
1 parent f2f2c1c commit 4db2ece

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

lib/index.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function getDependencies(analyzerBinaryPath, targetImage) {
6868
)
6969
.then(function (output) {
7070
scanResults = JSON.parse(output);
71-
return Promise.resolve(convertDependecies(targetImage, scanResults));
71+
return convertDependecies(targetImage, scanResults);
7272
})
7373
.catch(function (error) {
7474
if (typeof error === 'string') {
@@ -87,32 +87,32 @@ function getDependencies(analyzerBinaryPath, targetImage) {
8787
}
8888

8989
function convertDependecies(targetImage, scanResults) {
90-
targetSplit = targetImage.split(':');
91-
imageName = targetSplit[0];
92-
imageVersion = targetSplit[1];
93-
imageVersion = (imageVersion ? imageVersion : 'lateset');
90+
var targetSplit = targetImage.split(':');
91+
var imageName = targetSplit[0];
92+
var imageVersion = targetSplit[1] ? targetSplit[1] : 'latest';
9493

95-
root = {};
96-
root.name = imageName;
97-
root.version = imageVersion;
98-
99-
var scanResult = scanResults.filter(function (res) {
94+
var analysisResults = scanResults.results.filter(function (res) {
10095
return res.Analysis && res.Analysis.length > 0;
10196
})[0];
10297

10398
var pkgType;
104-
switch (scanResult.AnalyzeType) {
99+
switch (analysisResults.AnalyzeType) {
105100
case 'Apt': {
106101
pkgType = 'deb';
107102
break;
108103
}
109104
default: {
110-
pkgType = scanResult.AnalyzeType.toLowerCase()
105+
pkgType = analysisResults.AnalyzeType.toLowerCase()
111106
}
112107
}
113-
root.packageFormatVersion = pkgType + ':0.0.1';
114-
115-
pkgs = scanResult['Analysis']
108+
var root = {
109+
name: imageName,
110+
version: imageVersion,
111+
dockerOSRelease: scanResults.osRelease,
112+
packageFormatVersion: pkgType + ':0.0.1',
113+
};
114+
115+
var pkgs = analysisResults['Analysis'];
116116

117117
root.dependencies = pkgs.reduce(function (acc, pkg) {
118118
name = pkg['Name'];

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
1414
},
1515
"snyk-docker-analyzer": {
16-
"version": "1.0.6"
16+
"version": "1.1.0"
1717
},
1818
"author": "snyk.io",
1919
"license": "Apache-2.0",

0 commit comments

Comments
 (0)