Skip to content

Commit

Permalink
Update arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieMagee committed Dec 13, 2024
1 parent cfc25bb commit 6b62788
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
41 changes: 39 additions & 2 deletions src/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,52 @@ async function extractTarGz(filePath: string): Promise<string> {
return newName;
}

/**
* Get the arguments to pass to the Scorecard binary.
* @returns {string[]} The arguments to pass to the Scorecard binary.
*/
function getArguments(): string[] {
const args: string[] = [];

const repository = process.env["BUILD_REPOSITORY_URI"];
if (repository) {
args.push("--repo", repository);
}

const resultsFile = process.env["INPUT_RESULTSFILE"];
if (resultsFile) {
args.push("--output", resultsFile);
}

const resultsFormat = process.env["INPUT_RESULTSFORMAT"];
if (resultsFormat) {
args.push("--format", resultsFormat);
}

return args;
}

/**
* Run the Scorecard binary.
* @async
* @param binary The path to the Scorecard binary.
* @returns {Promise<void>} A promise that resolves when the command is executed.
*/
async function runScorecard(binary: string): Promise<void> {
const child = spawn(binary, ["--repo", "https://github.com/ossf/scorecard"], {
env: { SCORECARD_EXPERIMENTAL: "true" },
// const child = spawn(binary, getArguments(), {
// env: {
// AZURE_DEVOPS_AUTH_TOKEN:
// process.env["INPUT_REPOTOKEN"] ??
// process.env["AZURE_DEVOPS_AUTH_TOKEN"],
// SCORECARD_EXPERIMENTAL: "true",
// },
// });

const child = spawn(binary, ["--repo", "github.com/ossf/scorecard"], {
env: {
GITHUB_AUTH_TOKEN: process.env["INPUT_REPOTOKEN"],
SCORECARD_EXPERIMENTAL: "true",
},
});
child.stdout.on("data", (data) => {
console.log(data.toString());
Expand Down
9 changes: 8 additions & 1 deletion src/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"name": "resultsFile",
"label": "Results File",
"type": "filePath",
"required": true,
"required": false,
"helpMarkDown": "OUTPUT: Path to file where the results will be saved."
},
{
Expand All @@ -30,6 +30,13 @@
"sarif": "SARIF",
"json": "JSON"
}
},
{
"name": "repoToken",
"label": "Azure DevOps PAT",
"type": "string",
"required": false,
"helpMarkDown": "INPUT: Azure DevOps PAT with read access to the repository."
}
],
"execution": {
Expand Down

0 comments on commit 6b62788

Please sign in to comment.