Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from Oct 8, 2023

Conversation

3flex
Copy link
Member

@3flex 3flex commented Jul 30, 2023

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
Copy link
Member

TWiStErRob commented Aug 1, 2023

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

Copy link
Member

@TWiStErRob TWiStErRob left a comment

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
Copy link

codecov bot commented Oct 8, 2023

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
Copy link
Member Author

3flex commented Oct 8, 2023

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

@TWiStErRob
Copy link
Member

TWiStErRob commented Oct 8, 2023

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
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
22 of 23 checks passed
@3flex 3flex deleted the 4165-fix branch October 8, 2023 13:10
@hfhbd
Copy link
Contributor

hfhbd commented Oct 16, 2023

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
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
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
5 participants