Skip to content

Commit

Permalink
Do not attempt to sort the URL if it is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
NovemberTang committed Jun 11, 2024
1 parent 94528c1 commit 8febb57
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions packages/repocop/src/evaluation/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,20 +402,25 @@ export function evaluateOneRepo(

//create a predicate that orders a list of urls by whether they contain snyk.io first, and then github.com second
const urlSortPredicate = (url: string) => {
const parsedUrl = new URL(url);

if (
parsedUrl.hostname == 'snyk.io' ||
parsedUrl.hostname == 'security.snyk.io'
) {
return -2;
} else if (
parsedUrl.hostname == 'github.com' &&
parsedUrl.pathname.includes('advisories')
) {
return -1;
try {
const parsedUrl = new URL(url);

if (
parsedUrl.hostname == 'snyk.io' ||
parsedUrl.hostname == 'security.snyk.io'
) {
return -2;
} else if (
parsedUrl.hostname == 'github.com' &&
parsedUrl.pathname.includes('advisories')
) {
return -1;
}
return 0;
} catch {
//Do nothing if the url is invalid
return 0;
}
return 0;
};

export function dependabotAlertToRepocopVulnerability(
Expand Down

0 comments on commit 8febb57

Please sign in to comment.