diff --git a/src/main/index.ts b/src/main/index.ts index 31cc722..09b8aa8 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -123,7 +123,6 @@ async function runKnoxctlScan(): Promise { const knoxctlOptions = [ { name: "all", flag: "--all", type: "boolean" }, { name: "system", flag: "--system", type: "boolean" }, - { name: "output", flag: "--output", type: "string" }, { name: "ignore-alerts", flag: "--ignore-alerts", type: "string" }, { name: "min-severity", flag: "--min-severity", type: "string" }, ]; @@ -165,11 +164,12 @@ async function runKnoxctlScan(): Promise { policyCommand.push("--policies", policies); } - // Run the policy command first await exec.exec(policyCommand[0], policyCommand.slice(1)); const scanCommand: string[] = ["knoxctl", "scan"]; - let outputDir = getOutputDir(); + const outputDir = path.join(getOutputDir(), "knoxctl-results"); + + scanCommand.push("--output", outputDir); for (const option of knoxctlOptions) { let value: boolean | string; @@ -182,15 +182,11 @@ async function runKnoxctlScan(): Promise { } else if (option.type === "string") { value = core.getInput(option.name); if (value) { - if (option.name === "output") { - outputDir = value; - } scanCommand.push(option.flag, value); } } } - // Ensure the output directory exists if (!fs.existsSync(outputDir)) { log(`Creating output directory: ${outputDir}`); fs.mkdirSync(outputDir, { recursive: true }); diff --git a/src/post/index.ts b/src/post/index.ts index 0c96283..5bd5299 100644 --- a/src/post/index.ts +++ b/src/post/index.ts @@ -212,41 +212,8 @@ async function run(): Promise { // Increase wait time and add file system sync await new Promise((resolve) => setTimeout(resolve, 15000)); fs.readdirSync(getOutputDir()); // Force a file system sync - - // List contents of current working directory - const currentDir = process.cwd(); - log(`Current working directory: ${currentDir}`); - log("Contents of current working directory:"); - const currentDirFiles = fs.readdirSync(currentDir); - for (const file of currentDirFiles) { - const filePath = path.join(currentDir, file); - const stats = fs.statSync(filePath); - if (stats.isDirectory()) { - log(`- [DIR] ${file}`); - // List contents of subdirectories - const subDirFiles = fs.readdirSync(filePath); - for (const subFile of subDirFiles) { - log(` - ${subFile}`); - } - } else { - log(`- ${file}`); - } - } - - // List contents of expected output directory - const outputDir = getOutputDir(); - log(`\nExpected output directory: ${outputDir}`); - log("Contents of expected output directory:"); - if (fs.existsSync(outputDir)) { - const outputDirFiles = fs.readdirSync(outputDir); - for (const file of outputDirFiles) { - log(`- ${file}`); - } - } else { - log("Output directory does not exist."); - } - - await processResults(); + + await processResults(); await uploadArtifacts(outputDir);