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

⚠️ Warn and not fail if job perms are content:write #2355

Merged
merged 1 commit into from
Oct 17, 2022
Merged

⚠️ Warn and not fail if job perms are content:write #2355

merged 1 commit into from
Oct 17, 2022

Conversation

eddie-knight
Copy link
Contributor

@eddie-knight eddie-knight commented Oct 14, 2022

Following discussion in #2338, it has been determined that the permissions check should no longer deduct when a job is set to write. This code is a minimalist change, and will require additional polish/cleanup of obsolete logic later.

Signed-off-by: Eddie Knight [email protected]

What kind of change does this PR introduce?

Changes how scoring is done for token permissions

What is the current behavior?

The Token-Permissions check is opinionated regarding job-level permissions.

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

The Token-Permissions check now will only issue a warning regarding job-level permissions.

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

Which issue(s) this PR fixes

Fixes #2338

Special notes for your reviewer

I wasn't able to get the Token-Permissions check to report anything lower than 10/10 when running locally, even for repos that are less than 10 when checked via the API. As such, my validation checks were limited. I suggest a regular contributor or maintainer validates these changes before merging.

Does this PR introduce a user-facing change?

Job Level Permissions will no longer be evaluated on the Scorecard, but warnings will still be issued.

@spencerschrock
Copy link
Contributor

spencerschrock commented Oct 14, 2022

If we want to warn on write permissions, but not affect scoring if defined at the run level, this might be better addressed in the scoring code. Curious what others think. Various unit tests (make unit-test) check the number of debug, vs info, vs warn messages. Regardless of approach, some of the unit-tests will need changed as the expected scores will change.

func calculateScore(result map[string]permissions) int {

The various calls to permissionIsPresent could be replaced with permissionIsPresentInTopLevel for example.

@eddie-knight
Copy link
Contributor Author

Thanks @spencerschrock, I think it's a good idea to shift the change into the calculate function instead.

@eddie-knight eddie-knight temporarily deployed to integration-test October 14, 2022 21:21 Inactive
@github-actions
Copy link

Integration tests success for
[3e127da]
(https://github.com/ossf/scorecard/actions/runs/3253012126)

@eddie-knight eddie-knight marked this pull request as ready for review October 14, 2022 21:35
@eddie-knight eddie-knight changed the title ⚠️ Adjust to only warn if Job permissions are set to write ⚠️ Adjust to warn and not fail if job permissions are content:write Oct 14, 2022
@eddie-knight eddie-knight changed the title ⚠️ Adjust to warn and not fail if job permissions are content:write ⚠️ Adjust to warn and not fail if job perms are content:write Oct 14, 2022
@eddie-knight eddie-knight changed the title ⚠️ Adjust to warn and not fail if job perms are content:write ⚠️ Warn and not fail if job perms are content:write Oct 14, 2022
@codecov
Copy link

codecov bot commented Oct 14, 2022

Codecov Report

Merging #2355 (72d9e4e) into main (78c7e83) will not change coverage.
The diff coverage is 0.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2355   +/-   ##
=======================================
  Coverage   40.55%   40.55%           
=======================================
  Files         112      112           
  Lines        8822     8822           
=======================================
  Hits         3578     3578           
  Misses       4984     4984           
  Partials      260      260           

Copy link
Member

@naveensrinivasan naveensrinivasan left a comment

Choose a reason for hiding this comment

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

Thanks! I'll let @spencerschrock 👀

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.

LGTM overall. May be worth adding packages as that's another permission which results in a -10 deduction if not on the allowlist.

There's also an allowlist for security-events, but I imagine that's much less commonly used and only a -1 deduction.

@naveensrinivasan naveensrinivasan enabled auto-merge (squash) October 17, 2022 17:29
@naveensrinivasan naveensrinivasan temporarily deployed to integration-test October 17, 2022 17:29 Inactive
@github-actions
Copy link

Integration tests success for
[72d9e4e]
(https://github.com/ossf/scorecard/actions/runs/3267248107)

@naveensrinivasan naveensrinivasan merged commit c408592 into ossf:main Oct 17, 2022
@eddie-knight
Copy link
Contributor Author

Thanks @spencerschrock! I raised packages as a suggestion for discussion on #2338 so we can make a PR for that as well if there is agreement

@eddie-knight eddie-knight deleted the feature/job-permissions-warn branch October 17, 2022 18:23
latortuga71 pushed a commit to latortuga71/scorecard that referenced this pull request Oct 27, 2022
…ssf#2355)

Signed-off-by: Eddie Knight <[email protected]>

Signed-off-by: Eddie Knight <[email protected]>
Signed-off-by: latortuga <latortugaaaa>
N8BWert pushed a commit to N8BWert/scorecard that referenced this pull request Nov 28, 2022
…ssf#2355)

Signed-off-by: Eddie Knight <[email protected]>

Signed-off-by: Eddie Knight <[email protected]>
Signed-off-by: nathaniel.wert <[email protected]>
N8BWert pushed a commit to N8BWert/scorecard that referenced this pull request Nov 28, 2022
…ssf#2355)

Signed-off-by: Eddie Knight <[email protected]>

Signed-off-by: Eddie Knight <[email protected]>
Signed-off-by: nathaniel.wert <[email protected]>
raghavkaul pushed a commit to raghavkaul/scorecard that referenced this pull request Feb 9, 2023
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.

Explicitly allowed action permissions?
3 participants