UNPKG

snyk-docker-plugin

Version:
45 lines 2.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getPythonAppFileContentAction = exports.getPipAppFileContentAction = exports.getPoetryAppFileContentAction = void 0; const path_1 = require("path"); const stream_utils_1 = require("../../stream-utils"); const poetryManifestFiles = ["pyproject.toml", "poetry.lock"]; const pipManifestFiles = ["requirements.txt"]; const pythonMetadataFilesRegex = /\/lib\/python.*?\/(?:dist|site)-packages\/.*?\.dist-info\/METADATA/; const deletedPoetryAppFiles = poetryManifestFiles.map((file) => ".wh." + file); const deletedPipAppFiles = pipManifestFiles.map((file) => ".wh." + file); const pythonApplicationFileSuffixes = [".py", "requirements.txt", "Pipfile"]; function poetryFilePathMatches(filePath) { const fileName = (0, path_1.basename)(filePath); return (poetryManifestFiles.includes(fileName) || deletedPoetryAppFiles.includes(fileName)); } exports.getPoetryAppFileContentAction = { actionName: "poetry-app-files", filePathMatches: poetryFilePathMatches, callback: stream_utils_1.streamToString, }; function pipFilePathMatches(filePath) { const fileName = (0, path_1.basename)(filePath); return (pipManifestFiles.includes(fileName) || pythonMetadataFilesRegex.test(filePath) || deletedPipAppFiles.includes(fileName)); } exports.getPipAppFileContentAction = { actionName: "pip-app-files", filePathMatches: pipFilePathMatches, callback: stream_utils_1.streamToString, }; function pythonApplicationFilePathMatches(filePath) { return (!filePath.includes("/site-packages/") && !filePath.includes("/dist-packages/") && // "/usr/" should not include 1st party code !filePath.startsWith("/usr/") && pythonApplicationFileSuffixes.some((suffix) => filePath.endsWith(suffix))); } exports.getPythonAppFileContentAction = { actionName: "python-app-files", filePathMatches: pythonApplicationFilePathMatches, callback: stream_utils_1.streamToString, }; //# sourceMappingURL=static.js.map