Skip to content

Commit a1170a7

Browse files
Merge pull request #15 from devopsabcs-engineering/feature/2023-fix-ibm-helpurl-latest Fixes AB#2023
fix: normalize IBM helpUrl to use /archives/latest/ instead of versio… Fixes AB#2023
2 parents 1552e70 + f133532 commit a1170a7

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/lib/report/__tests__/sarif-generator.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ describe('generateSarif', () => {
152152
it('IBM rule IDs with underscores produce valid markdown links', () => {
153153
const violations = [makeViolation({
154154
id: 'label_name_visible',
155-
helpUrl: 'https://able.ibm.com/rules/archives/2026.03.04/doc/en-US/label_name_visible.html',
155+
helpUrl: 'https://able.ibm.com/rules/archives/latest/doc/en-US/label_name_visible.html',
156156
})];
157157
const sarif = generateSarif('https://example.com', violations, '1.0.0');
158158
const markdown = sarif.runs[0].tool.driver.rules[0].help.markdown;
159-
expect(markdown).toContain('[Rule documentation](https://able.ibm.com/rules/archives/2026.03.04/doc/en-US/label_name_visible.html)');
159+
expect(markdown).toContain('[Rule documentation](https://able.ibm.com/rules/archives/latest/doc/en-US/label_name_visible.html)');
160160
expect(markdown).not.toContain('label\\_name');
161161
});
162162
});

src/lib/scanner/__tests__/result-normalizer.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,12 @@ describe('normalizeIbmResults', () => {
169169
expect(result[0].helpUrl).toBe('https://able.ibm.com/rules/archives/latest/doc/en-US/img_alt_valid.html');
170170
});
171171

172-
it('extracts base URL from IBM help field', () => {
172+
it('extracts base URL from IBM help field and normalizes to latest archive', () => {
173173
const result = normalizeIbmResults([makeIbmResult({
174174
ruleId: 'style_color_misuse',
175175
help: 'https://able.ibm.com/rules/archives/2026.03.04/doc/en-US/style_color_misuse.html#ruleInfo=%7B%22someKey%22%3A%22someValue%22%7D',
176176
})]);
177-
expect(result[0].helpUrl).toBe('https://able.ibm.com/rules/archives/2026.03.04/doc/en-US/style_color_misuse.html');
177+
expect(result[0].helpUrl).toBe('https://able.ibm.com/rules/archives/latest/doc/en-US/style_color_misuse.html');
178178
});
179179

180180
it('falls back to archive URL when help is not a URL', () => {
@@ -191,6 +191,7 @@ describe('normalizeIbmResults', () => {
191191
help: 'https://able.ibm.com/rules/archives/2026.03.04/doc/en-US/some_rule.html',
192192
})]);
193193
expect(result[0].help).toBe('Human readable text');
194+
expect(result[0].helpUrl).toBe('https://able.ibm.com/rules/archives/latest/doc/en-US/some_rule.html');
194195
});
195196

196197
it('includes category as a tag when present', () => {

src/lib/scanner/result-normalizer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ function extractIbmHelpUrl(rawHelp: string | undefined, ruleId: string): string
5656
if (rawHelp) {
5757
try {
5858
const url = new URL(rawHelp);
59-
return `${url.origin}${url.pathname}`;
59+
const ruleFile = url.pathname.split('/').pop();
60+
if (ruleFile) {
61+
return `https://able.ibm.com/rules/archives/latest/doc/en-US/${ruleFile}`;
62+
}
6063
} catch {
6164
// not a URL, fall through
6265
}

0 commit comments

Comments
 (0)