Skip to content

Commit 5117010

Browse files
authored
fix: Add dummy location data to conform to SARIF spec (#988)
#### Details As called out in #961, our SARIF doesn't have a fully formed location. Since we don't have meaningful data for this, the "least bad" solution was to insert dummy data for the `startLine` property. This PR includes 2 code changes, plus a bunch of refreshed SARIF files generated via the CLI tool. I noticed that the refreshed version of `basic-axe-3.2.2.sarif` is pretty-printed differently than what we had before. I'm guessing that the tool shifted at some point and that this is the first time the file has been regenerated with the current tool. ##### Motivation Address #961 for better tool compatibility ##### Context <!-- Are there any parts that you've intentionally left out-of-scope for a later PR to handle? --> <!-- Were there any alternative approaches you considered? What tradeoffs did you consider? --> #### Pull request checklist <!-- If a checklist item is not applicable to this change, write "n/a" in the checkbox --> - [x] PR title respects [Conventional Commits](https://www.conventionalcommits.org) (starts with `fix:`, `feat:`, etc, and is suitable for user-facing release notes) - [x] PR contains no breaking changes, **OR** description of both PR **and final merge commit** starts with `BREAKING CHANGE:` - [x] (if applicable) Addresses issue: #961 - [n/a] Added relevant unit tests for your changes - [x] Ran `yarn precheckin` - [x] Verified code coverage for the changes made
1 parent fb5818c commit 5117010

34 files changed

+9832
-695
lines changed

src/axe-raw-sarif-converter.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { EnvironmentData } from './environment-data';
1515
import { getInvocations } from './invocation-provider';
1616
import { ResultToRuleConverter } from './result-to-rule-converter';
1717
import { formatSarifResultMessage } from './sarif-result-message-formatter';
18-
import { axeTagsToWcagLinkData, WCAGLinkData } from './wcag-link-data';
18+
import { WCAGLinkData, axeTagsToWcagLinkData } from './wcag-link-data';
1919
import { WCAGLinkDataIndexer } from './wcag-link-data-indexer';
2020
import { getWcagTaxonomy } from './wcag-taxonomy-provider';
2121

@@ -174,6 +174,7 @@ export class AxeRawSarifConverter {
174174
physicalLocation: {
175175
artifactLocation: getArtifactLocation(environmentData),
176176
region: {
177+
startLine: 1,
177178
snippet: {
178179
text: axeRawNodeResult.node.source,
179180
},

src/sarif-converter.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { getEnvironmentDataFromResults } from './environment-data-provider';
1515
import { getInvocations } from './invocation-provider';
1616
import { ResultToRuleConverter } from './result-to-rule-converter';
1717
import { formatSarifResultMessage } from './sarif-result-message-formatter';
18-
import { axeTagsToWcagLinkData, WCAGLinkData } from './wcag-link-data';
18+
import { WCAGLinkData, axeTagsToWcagLinkData } from './wcag-link-data';
1919
import { WCAGLinkDataIndexer } from './wcag-link-data-indexer';
2020
import { getWcagTaxonomy } from './wcag-taxonomy-provider';
2121

@@ -176,6 +176,7 @@ export class SarifConverter {
176176
physicalLocation: {
177177
artifactLocation: getArtifactLocation(environmentData),
178178
region: {
179+
startLine: 1,
179180
snippet: {
180181
text: node.html,
181182
},

0 commit comments

Comments
 (0)