snyk-docker-plugin
Version:
Snyk CLI docker plugin
55 lines • 1.53 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.mapRpmSqlitePackages = exports.analyze = void 0;
const types_1 = require("../types");
function analyze(targetImage, rpmDbFilecontent) {
return Promise.resolve({
Image: targetImage,
AnalyzeType: types_1.AnalysisType.Rpm,
Analysis: parseOutput(rpmDbFilecontent),
});
}
exports.analyze = analyze;
function parseOutput(output) {
const pkgs = [];
for (const line of output.split("\n")) {
parseLine(line, pkgs);
}
return pkgs;
}
function parseLine(text, pkgs) {
const [name, version, size] = text.split("\t");
if (name && version && size) {
const pkg = {
Name: name,
Version: version,
Source: undefined,
Provides: [],
Deps: {},
AutoInstalled: undefined,
};
pkgs.push(pkg);
}
}
function mapRpmSqlitePackages(targetImage, rpmPackages) {
let analysis;
if (rpmPackages) {
analysis = rpmPackages.map((pkg) => {
return {
Name: pkg.name,
Version: pkg.version,
Source: undefined,
Provides: [],
Deps: {},
AutoInstalled: undefined,
};
});
}
return {
Image: targetImage,
AnalyzeType: types_1.AnalysisType.Rpm,
Analysis: analysis,
};
}
exports.mapRpmSqlitePackages = mapRpmSqlitePackages;
//# sourceMappingURL=rpm.js.map
;