Skip to content

Commit

Permalink
fix(scorecard): add missing options from new major
Browse files Browse the repository at this point in the history
  • Loading branch information
fraxken committed Jul 31, 2024
1 parent 2c512e1 commit 5a66ec7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
11 changes: 9 additions & 2 deletions src/plugins/scorecard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ export async function execute(
orgName: string,
repository: DashlogRepository<ScorecardPlugin>
) {
const scorecard = await fetchOpenSSFScorecard(orgName, repository.name);
const scorecard = await fetchOpenSSFScorecard(
orgName,
repository.name
);

Object.assign(repository.plugins, { scorecard });
}

Expand All @@ -21,7 +25,10 @@ async function fetchOpenSSFScorecard(
repositoryName: string
): Promise<scorecard.ScorecardResult | null> {
try {
return await scorecard.result(`${orgName}/${repositoryName}`);
return await scorecard.result(`${orgName}/${repositoryName}`, {
resolveOnNpmRegistry: false,
resolveOnVersionControl: false
});
}
catch {
return null;
Expand Down
27 changes: 19 additions & 8 deletions test/plugins/scorecard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,34 @@ describe("execute()", async() => {
});

it("should fetch scorecard", async() => {
mockPool.intercept({ path: "/projects/github.com/NodeSecure/ossf-scorecard-sdk" }).reply(200, { foo: "bar" }, {
headers: { "Content-Type": "application/json" }
}).times(1);

const repo: any = { name: "ossf-scorecard-sdk", plugins: {} };
mockPool
.intercept({
path: "/projects/github.com/NodeSecure/ossf-scorecard-sdk"
})
.reply(200, { foo: "bar" }, {
headers: { "Content-Type": "application/json" }
})
.times(1);

const repo: any = {
name: "ossf-scorecard-sdk",
plugins: {}
};

await execute("NodeSecure", repo);
assert.equal(repo.plugins.scorecard.foo, "bar");
assert.strictEqual(repo.plugins.scorecard.foo, "bar");
});

it("should return null", async() => {
mockPool.intercept({ path: "/projects/github.com/NodeSecure/cli" }).reply(404).times(1);
mockPool
.intercept({ path: "/projects/github.com/NodeSecure/cli" })
.reply(404)
.times(1);

const repo: any = { name: "cli", plugins: {} };

await execute("NodeSecure", repo);
assert.equal(repo.plugins.scorecard, null);
assert.strictEqual(repo.plugins.scorecard, null);
});
});

Expand Down

0 comments on commit 5a66ec7

Please sign in to comment.