Skip to content

Correctly set scheme for URIs in the SARIF report output - #6331

Merged
3flex merged 4 commits into
detekt:mainfrom
3flex:4165-fix
Oct 8, 2023
Merged

3flex merged 4 commits into
detekt:mainfrom
3flex:4165-fix

Conversation

@3flex

@3flex 3flex commented Jul 30, 2023

Copy link
Copy Markdown
Member

Fixes #4165

@TWiStErRob it would be great if you could test this - I've reviewed the output locally but haven't submitted anything to GitHub.

@3flex
3flex requested a review from TWiStErRob July 30, 2023 06:59
@TWiStErRob

This comment was marked as outdated.

@TWiStErRob

TWiStErRob commented Aug 1, 2023 •

Copy link
Copy Markdown
Member

Sorry, it took me a while to start on this :) Here are my findings.

Test setup

https://github.com/TWiStErRob/detekt-4165

  • A project with DGP applied
  • 2 files in 2 modules producing MagicNumber
  • CI that runs on all 3 OSs
  • detekt built from sources, so we can use this branch!

Reports

Main branch CI: https://github.com/TWiStErRob/detekt-4165/actions/runs/5728342547
This PR's CI: https://github.com/TWiStErRob/detekt-4165/actions/runs/5728353537?pr=1
Main findings: https://github.com/TWiStErRob/detekt-4165/security/code-scanning?query=is%3Aopen+branch%3Amain+
Branch findings: https://github.com/TWiStErRob/detekt-4165/security/code-scanning?query=is%3Aopen+branch%3Afix

Results

Next steps

  • @3flex if you fix the "toURI()" function to be correct on all platforms I think we're good.
  • I can easily re-execute the CI on the other repo to confirm.

BraisGabin
BraisGabin previously approved these changes Oct 7, 2023
@BraisGabin
BraisGabin dismissed their stale review October 7, 2023 10:40

I didn't see the test results

@TWiStErRob TWiStErRob left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub is now very happy with these changes!

https://github.com/TWiStErRob/detekt-4165/security/code-scanning?query=pr%3A1+tool%3Adetekt+is%3Aopen

Screenshots

image

image

Notice:

  • There were 6 reports in the past, linux, mac, windows. 4/6 were not navigable.
  • After your recent force-push, the original 6 issues were closed, and now there are only 2 detected 3 times by separate CI jobs.
  • This means that the paths (including base dirs) cancel each other out, and it doesn't matter which platform you run detekt on, GitHub will see them just the same! 🎉

@codecov

codecov Bot commented Oct 8, 2023 •

Copy link
Copy Markdown

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (f3308a1) 85.18% compared to head (71713e3) 85.18%.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #6331   +/-   ##
=========================================
  Coverage     85.18%   85.18%           
  Complexity     4037     4037           
=========================================
  Files           564      564           
  Lines         13273    13274    +1     
  Branches       2387     2387           
=========================================
+ Hits          11306    11307    +1     
  Misses          773      773           
  Partials       1194     1194           
Files Coverage Δ
...in/kotlin/io/github/detekt/report/sarif/Results.kt 93.75% <100.00%> (ø)
...io/github/detekt/report/sarif/SarifOutputReport.kt 87.50% <100.00%> (+0.40%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@3flex

3flex commented Oct 8, 2023

Copy link
Copy Markdown
Member Author

@TWiStErRob if you could have a final look before merging that would be appreciated, thanks!

@TWiStErRob

TWiStErRob commented Oct 8, 2023 •

Copy link
Copy Markdown
Member

Trying to run the integration tests, but need to update the repro with Gradle 8.4 and detekt mainline (see #6523 (comment)).

@TWiStErRob

Copy link
Copy Markdown
Member

Seems ok https://github.com/TWiStErRob/detekt-4165-2/security/code-scanning/2

The same issue is detected by all 3 platforms and preview is working:
image

@3flex
3flex merged commit 7babf23 into detekt:main Oct 8, 2023
@3flex
3flex deleted the 4165-fix branch October 8, 2023 13:10
@hfhbd

hfhbd commented Oct 16, 2023

Copy link
Copy Markdown
Contributor

Any chance to get a release containing this fix before detekt 2.0?

@BraisGabin BraisGabin added the pick request Marker for PRs that should be ported to the 1.0 release branch label Oct 16, 2023
@cortinico

Copy link
Copy Markdown
Member

Any chance to get a release containing this fix before detekt 2.0?

I'll include this in the upcoming 1.23.x release

cortinico pushed a commit that referenced this pull request Oct 30, 2023
* Correctly set scheme for URIs in the SARIF report output

* Update tests

* Remove unused class

* Use toUri to generate absolute ArtifactLocation paths
mgroth0 pushed a commit to mgroth0/detekt that referenced this pull request Feb 11, 2024
* Correctly set scheme for URIs in the SARIF report output

* Update tests

* Remove unused class

* Use toUri to generate absolute ArtifactLocation paths

This branch was successfully deployed

1 active deployment
Preview — 71713e38 Deployed Oct 8, 2023 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pick request Marker for PRs that should be ported to the 1.0 release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sarif output from detekt is not finding paths on GitHub

6 participants