Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function downloadInlineScan(version) {
core.debug(`Installing ${version}`);
const downloadPath = await cache.downloadTool(`https://ci-tools.anchore.io/inline_scan-v${version}`);
// Make sure the tool's executable bit is set
await exec(`chmod +x ${downloadPath}`);
// Cache the downloaded file
return cache.cacheFile(downloadPath, scanScript, scanScript, version);
}
return __awaiter(this, void 0, void 0, function* () {
let cachedToolpath = toolCache.find(kubectlToolName, version);
let kubectlDownloadPath = '';
if (!cachedToolpath) {
try {
kubectlDownloadPath = yield toolCache.downloadTool(getkubectlDownloadURL(version));
}
catch (exception) {
throw new Error('DownloadKubectlFailed');
}
cachedToolpath = yield toolCache.cacheFile(kubectlDownloadPath, kubectlToolName + getExecutableExtension(), kubectlToolName, version);
}
const kubectlPath = path.join(cachedToolpath, kubectlToolName + getExecutableExtension());
fs.chmodSync(kubectlPath, '777');
return kubectlPath;
});
}
async function acquireOpamLinux(version: string): Promise {
let opamVersion: string = "2.0.5"
let fileName: string = getOpamFileName(opamVersion);
let downloadUrl: string = getOpamDownloadUrl(opamVersion, fileName);
let downloadPath: string | null = null;
try {
downloadPath = await tc.downloadTool(downloadUrl);
} catch (error) {
core.debug(error);
throw `Failed to download version ${opamVersion}: ${error}`;
}
fs.chmodSync(downloadPath, '755');
let toolPath : string = await tc.cacheFile(downloadPath, 'opam', 'opam', opamVersion);
core.addPath(toolPath);
await exec.exec("sudo apt-get -y install bubblewrap ocaml-native-compilers ocaml-compiler-libs");
await exec.exec(`"${toolPath}/opam"`, ["init", "-yav"]);
await exec.exec(path.join(__dirname, 'install-ocaml-unix.sh'),[version]);
await exec.exec(`"${toolPath}/opam"`, ["install", "-y", "depext"]);
}
async function downloadKubectl(version: string): Promise {
let cachedToolpath = toolCache.find(kubectlToolName, version);
let kubectlDownloadPath = '';
if (!cachedToolpath) {
try {
kubectlDownloadPath = await toolCache.downloadTool(getkubectlDownloadURL(version));
} catch (exception) {
throw new Error('DownloadKubectlFailed');
}
cachedToolpath = await toolCache.cacheFile(kubectlDownloadPath, kubectlToolName + getExecutableExtension(), kubectlToolName, version);
}
const kubectlPath = path.join(cachedToolpath, kubectlToolName + getExecutableExtension());
fs.chmodSync(kubectlPath, '777');
return kubectlPath;
}
async function acquireOpamWindows(version: string): Promise {
let downloadPath: string | null = null;
let toolPath : string | null = null;
try {
downloadPath = await tc.downloadTool("https://cygwin.com/setup-x86_64.exe");
} catch (error) {
core.debug(error);
throw `Failed to download cygwin: ${error}`;
}
toolPath = await tc.cacheFile(downloadPath, 'setup-x86_64.exe', 'cygwin', "1.0");
await exec.exec(path.join(__dirname, 'install-ocaml-windows.cmd'),[__dirname, toolPath, version]);
core.addPath("c:\\cygwin\\bin");
core.addPath("c:\\cygwin\\wrapperbin");
}