Skip to content

Commit

Permalink
feat(vulnerabilities): Add Hackage support (#33328)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Kriese <[email protected]>
  • Loading branch information
ysangkok and viceice authored Jan 1, 2025
1 parent dd90388 commit 1caffcc
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/usage/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -2426,6 +2426,7 @@ Renovate only queries the OSV database for dependencies that use one of these da

- [`crate`](./modules/datasource/crate/index.md)
- [`go`](./modules/datasource/go/index.md)
- [`hackage`](./modules/datasource/hackage/index.md)
- [`hex`](./modules/datasource/hex/index.md)
- [`maven`](./modules/datasource/maven/index.md)
- [`npm`](./modules/datasource/npm/index.md)
Expand Down
2 changes: 1 addition & 1 deletion lib/workers/repository/init/vulnerability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function getFixedVersionByDatasource(
return `[${fixedVersion},)`;
}

// crates.io, Go, Hex, npm, RubyGems, PyPI
// crates.io, Go, Hackage, Hex, npm, RubyGems, PyPI
return `>= ${fixedVersion}`;
}

Expand Down
57 changes: 57 additions & 0 deletions lib/workers/repository/process/vulnerabilities.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,63 @@ describe('workers/repository/process/vulnerabilities', () => {
]);
});

it('returns packageRules for Hackage', async () => {
const packageFiles: Record<string, PackageFile[]> = {
hackage: [
{
deps: [
{
depName: 'aeson',
currentValue: '0.4.0.0',
datasource: 'hackage',
},
],
packageFile: 'some-file',
},
],
};
getVulnerabilitiesMock.mockResolvedValueOnce([
{
id: 'HSEC-2023-0001',
summary: 'Hash flooding vulnerability in aeson',
details:
'# Hash flooding vulnerability in aeson\n\n*aeson* was vulnerable to hash flooding (a.k.a. hash DoS). The\nissue is a consequence of the HashMap implementation from\n*unordered-containers*. It results in a denial of service through\nCPU consumption. This technique has been used in real-world attacks\nagainst a variety of languages, libraries and frameworks over the\nyears.\n',
aliases: ['CVE-2022-3433'],
modified: '2023-06-13T09:03:52Z',
affected: [
{
package: {
ecosystem: 'Hackage',
name: 'aeson',
},
ranges: [
{
type: 'ECOSYSTEM',
events: [{ introduced: '0.4.0.0' }, { fixed: '2.0.1.0' }],
},
],
},
],
},
]);

await vulnerabilities.appendVulnerabilityPackageRules(
config,
packageFiles,
);

expect(config.packageRules).toHaveLength(1);
expect(config.packageRules).toMatchObject([
{
matchDatasources: ['hackage'],
matchPackageNames: ['aeson'],
matchCurrentVersion: '0.4.0.0',
allowedVersions: '>= 2.0.1.0',
isVulnerabilityAlert: true,
},
]);
});

it('filters not applicable vulnerability based on last_affected version', async () => {
const packageFiles: Record<string, PackageFile[]> = {
poetry: [
Expand Down
1 change: 1 addition & 0 deletions lib/workers/repository/process/vulnerabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class Vulnerabilities {
> = {
crate: 'crates.io',
go: 'Go',
hackage: 'Hackage',
hex: 'Hex',
maven: 'Maven',
npm: 'npm',
Expand Down

0 comments on commit 1caffcc

Please sign in to comment.