microsoft / microsoft/sarif-web-component

parsing.ts errors if a result does not have a locations property

Open
#2 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
108
Forks
36
Avg merge
5d 15h
Merged PRs (30d)
3

Description

The SARIF spec allows for a Result to omit the locations property (it says that results SHOULD include it, rather than SHALL or MUST include it). However, parsing.ts line 53 unconditionally runs const loc0 = r.locations[0] on all results it parses, and emits an error like this if there is a result with no locations property:

parsing.ts:50 Uncaught (in promise) TypeError: Cannot read property '0' of undefined
    at eval (parsing.ts:50)
    at Array.map (<anonymous>)
    at eval (parsing.ts:48)
    at Array.map (<anonymous>)
    at Object.parse (parsing.ts:31)
    at async eval (ResultsViewer.tsx:28)

The viewer should treat such results the same as it does results with an empty locations array.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in parsing.ts around line 53, then review the result handling used by ResultsViewer.tsx. Reproduce parsing with a SARIF result that omits locations and make it behave like a result with an empty locations array; done means no TypeError and the viewer continues to parse the result.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.