Skip to content

Commit

Permalink
fix: Add dummy location data to conform to SARIF spec (#988)
Browse files Browse the repository at this point in the history
#### 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
  • Loading branch information
DaveTryon authored May 22, 2023
1 parent fb5818c commit 5117010
Show file tree
Hide file tree
Showing 34 changed files with 9,832 additions and 695 deletions.
3 changes: 2 additions & 1 deletion src/axe-raw-sarif-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { EnvironmentData } from './environment-data';
import { getInvocations } from './invocation-provider';
import { ResultToRuleConverter } from './result-to-rule-converter';
import { formatSarifResultMessage } from './sarif-result-message-formatter';
import { axeTagsToWcagLinkData, WCAGLinkData } from './wcag-link-data';
import { WCAGLinkData, axeTagsToWcagLinkData } from './wcag-link-data';
import { WCAGLinkDataIndexer } from './wcag-link-data-indexer';
import { getWcagTaxonomy } from './wcag-taxonomy-provider';

Expand Down Expand Up @@ -174,6 +174,7 @@ export class AxeRawSarifConverter {
physicalLocation: {
artifactLocation: getArtifactLocation(environmentData),
region: {
startLine: 1,
snippet: {
text: axeRawNodeResult.node.source,
},
Expand Down
3 changes: 2 additions & 1 deletion src/sarif-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { getEnvironmentDataFromResults } from './environment-data-provider';
import { getInvocations } from './invocation-provider';
import { ResultToRuleConverter } from './result-to-rule-converter';
import { formatSarifResultMessage } from './sarif-result-message-formatter';
import { axeTagsToWcagLinkData, WCAGLinkData } from './wcag-link-data';
import { WCAGLinkData, axeTagsToWcagLinkData } from './wcag-link-data';
import { WCAGLinkDataIndexer } from './wcag-link-data-indexer';
import { getWcagTaxonomy } from './wcag-taxonomy-provider';

Expand Down Expand Up @@ -176,6 +176,7 @@ export class SarifConverter {
physicalLocation: {
artifactLocation: getArtifactLocation(environmentData),
region: {
startLine: 1,
snippet: {
text: node.html,
},
Expand Down
Loading

0 comments on commit 5117010

Please sign in to comment.