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

🌱 migrate token permission check to probes #3816

Merged
merged 30 commits into from
Mar 22, 2024

Conversation

AdamKorcz
Copy link
Contributor

What kind of change does this PR introduce?

(Is it a bug fix, feature, docs update, something else?)

What is the current behavior?

What is the new behavior (if this is a feature change)?**

  • Tests for the changes have been added (for bug fixes/features)

Which issue(s) this PR fixes

Special notes for your reviewer

Does this PR introduce a user-facing change?

For user-facing changes, please add a concise, human-readable release note to
the release-note

(In particular, describe what changes users might need to make in their
application as a result of this pull request.)


Copy link

codecov bot commented Jan 22, 2024

Codecov Report

Merging #3816 (096a1b2) into main (c1066d9) will decrease coverage by 4.36%.
The diff coverage is 78.93%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3816      +/-   ##
==========================================
- Coverage   74.87%   70.52%   -4.36%     
==========================================
  Files         223      227       +4     
  Lines       15993    16263     +270     
==========================================
- Hits        11975    11469     -506     
- Misses       3254     4067     +813     
+ Partials      764      727      -37     

Copy link

github-actions bot commented Feb 6, 2024

This pull request is stale because it has been open for 10 days with no activity

@AdamKorcz
Copy link
Contributor Author

@spencerschrock I combined the probes into top level and job level write probes. I kept it write-all probes as I would otherwise add more complexity to the evaluation.

Copy link
Contributor

@spencerschrock spencerschrock left a comment

Choose a reason for hiding this comment

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

Left some partial feedback (which can potentially be ignored depending on the rest of this message). I'm noticing there's a difference in approach here compared to the rawToFindings approach that the code did before.

I believe that approach did 2 probes (top and job), which I thought is what we discussed above. So I was a little surprised to see 8 here still.

checker/raw_result.go Outdated Show resolved Hide resolved
checks/evaluation/permissions.go Outdated Show resolved Hide resolved
checks/evaluation/permissions.go Outdated Show resolved Hide resolved
checks/evaluation/permissions.go Outdated Show resolved Hide resolved
checks/evaluation/permissions.go Show resolved Hide resolved
probes/hasGitHubWorkflowPermissionUndeclared/def.yml Outdated Show resolved Hide resolved
probes/hasGitHubWorkflowPermissionUnknown/impl.go Outdated Show resolved Hide resolved
probes/hasGitHubWorkflowPermissionUnknown/def.yml Outdated Show resolved Hide resolved
probes/internal/utils/permissions/permissions.go Outdated Show resolved Hide resolved
probes/internal/utils/permissions/permissions.go Outdated Show resolved Hide resolved
Signed-off-by: Adam Korczynski <adam@adalogics.com>
Signed-off-by: Adam Korczynski <adam@adalogics.com>
Signed-off-by: Adam Korczynski <adam@adalogics.com>
Signed-off-by: Adam Korczynski <adam@adalogics.com>
Signed-off-by: Adam Korczynski <adam@adalogics.com>
Signed-off-by: Adam Korczynski <adam@adalogics.com>
Signed-off-by: Adam Korczynski <adam@adalogics.com>
Signed-off-by: Adam Korczynski <adam@adalogics.com>
…otAvailableOrNotApplicable

Signed-off-by: Adam Korczynski <adam@adalogics.com>
Signed-off-by: Adam Korczynski <adam@adalogics.com>
Signed-off-by: Adam Korczynski <adam@adalogics.com>
Signed-off-by: Adam Korczynski <adam@adalogics.com>
Signed-off-by: Adam Korczynski <adam@adalogics.com>
@spencerschrock
Copy link
Contributor

/scdiff generate Token-Permissions

Copy link

probes/hasNoGitHubWorkflowPermissionUnknown/def.yml Outdated Show resolved Hide resolved
probes/jobLevelPermissions/def.yml Outdated Show resolved Hide resolved
probes/topLevelPermissions/def.yml Outdated Show resolved Hide resolved
Signed-off-by: Adam Korczynski <adam@adalogics.com>
@spencerschrock spencerschrock merged commit 5b0ae81 into ossf:main Mar 22, 2024
38 checks passed
fhoeborn pushed a commit to fhoeborn/scorecard that referenced this pull request Apr 1, 2024
* 🌱 migrate token permission check to probes

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* combine seperate write-probes into two that combine them all

Signed-off-by: AdamKorcz <adam@adalogics.com>

* change write probes to read and write

Signed-off-by: AdamKorcz <adam@adalogics.com>

* minor nit

Signed-off-by: AdamKorcz <adam@adalogics.com>

* remove WritaAll probes

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* Merge read-perm probe with job/top probes

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* minor refactoring

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* fix copy paste error

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* fix linter issues and restructure code

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* remove hasGitHubWorkflowPermissionNone probe

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* Remove 'hasGitHubWorkflowPermissionUndeclared' probe

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* bit of clean up

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* reduce code complexity and remove comment

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* simplify file location

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* change probe text

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* invert name of probe

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* OutcomeNotApplicable -> OutcomeError

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* OutcomeNotAvailable -> OutcomeNotApplicable

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* more OutcomeNotAvailable -> OutcomeNotApplicable

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* change name of 'notAvailableOrNotApplicable'

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* fix linter issues

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* add comments to remediation fields

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* add check for nil-dereference

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* remove the permissionLocation finding value

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* rename checkAndLogNotAvailableOrNotApplicable to isBothUndeclaredAndNotAvailableOrNotApplicable

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* use raw metadata for remediation output

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* change 'branch' to 'defaultBranch'

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* remove unused fields in rule Remediation

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* fix remediation

Signed-off-by: Adam Korczynski <adam@adalogics.com>

* change 'metadata.defaultBranch' to 'metadata.repository.defaultBranch'

Signed-off-by: Adam Korczynski <adam@adalogics.com>

---------

Signed-off-by: Adam Korczynski <adam@adalogics.com>
Signed-off-by: AdamKorcz <adam@adalogics.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants