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

The "Token-Permissions" check seems to complain about codeql and labeler #1257

Closed
evverx opened this issue Nov 13, 2021 · 37 comments
Closed
Labels
kind/bug Something isn't working

Comments

@evverx
Copy link
Contributor

evverx commented Nov 13, 2021

Both codeql and labeler are widely used GH Actions that require non read-only tokens. The links to the "official" documentation where the permissions they have to have are mentioned:
https://github.com/github/codeql-action#usage
https://docs.github.com/en/actions/security-guides/automatic-token-authentication#example-1-passing-the-github_token-as-an-input

./scorecard --verbosity Debug --checks Token-Permissions --show-details --format json  --repo=https://github.com/systemd/systemd | jq
...
      "details": [
        "Info: permissions set to 'read-all': .github/workflows/build_test.yml:1",
        "Debug: not a publishing workflow: .github/workflows/build_test.yml:1",
        "Debug: not a codeql workflow: .github/workflows/build_test.yml:1",
        "Debug: not a codeql upload SARIF workflow: .github/workflows/build_test.yml:1",
        "Debug: no permission defined: .github/workflows/build_test.yml:1",
        "Info: permissions set to 'read-all': .github/workflows/cifuzz.yml:1",
        "Debug: not a publishing workflow: .github/workflows/cifuzz.yml:1",
        "Debug: not a codeql workflow: .github/workflows/cifuzz.yml:1",
        "Debug: not a codeql upload SARIF workflow: .github/workflows/cifuzz.yml:1",
        "Debug: no permission defined: .github/workflows/cifuzz.yml:1",
        "Warn: no permission defined: .github/workflows/codeql-analysis.yml:1",
        "Debug: not a publishing workflow: .github/workflows/codeql-analysis.yml:1",
        "Debug: codeql workflow detected: .github/workflows/codeql-analysis.yml:1",
        "Info: 'actions' permission set to 'read': .github/workflows/codeql-analysis.yml:1",
        "Info: 'contents' permission set to 'read': .github/workflows/codeql-analysis.yml:1",
        "Debug: 'security-events' permission set to 'write': .github/workflows/codeql-analysis.yml:1",
        "Info: permissions set to 'read-all': .github/workflows/coverity.yml:1",
        "Debug: not a publishing workflow: .github/workflows/coverity.yml:1",
        "Debug: not a codeql workflow: .github/workflows/coverity.yml:1",
        "Debug: not a codeql upload SARIF workflow: .github/workflows/coverity.yml:1",
        "Debug: no permission defined: .github/workflows/coverity.yml:1",
        "Info: 'contents' permission set to 'read': .github/workflows/labeler.yml:1",
        "Debug: 'pull-requests' permission set to 'write': .github/workflows/labeler.yml:1",
        "Debug: not a publishing workflow: .github/workflows/labeler.yml:1",
        "Debug: not a codeql workflow: .github/workflows/labeler.yml:1",
        "Debug: not a codeql upload SARIF workflow: .github/workflows/labeler.yml:1",
        "Debug: no permission defined: .github/workflows/labeler.yml:1",
        "Info: permissions set to 'read-all': .github/workflows/linter.yml:1",
        "Debug: not a publishing workflow: .github/workflows/linter.yml:1",
        "Debug: not a codeql workflow: .github/workflows/linter.yml:1",
        "Debug: not a codeql upload SARIF workflow: .github/workflows/linter.yml:1",
        "Debug: no permission defined: .github/workflows/linter.yml:1",
        "Info: permissions set to 'read-all': .github/workflows/mkosi.yml:1",
        "Debug: not a publishing workflow: .github/workflows/mkosi.yml:1",
        "Debug: not a codeql workflow: .github/workflows/mkosi.yml:1",
        "Debug: not a codeql upload SARIF workflow: .github/workflows/mkosi.yml:1",
        "Debug: no permission defined: .github/workflows/mkosi.yml:1",
        "Info: permissions set to 'read-all': .github/workflows/unit_tests.yml:1",
        "Debug: not a publishing workflow: .github/workflows/unit_tests.yml:1",
        "Debug: not a codeql workflow: .github/workflows/unit_tests.yml:1",
        "Debug: not a codeql upload SARIF workflow: .github/workflows/unit_tests.yml:1",
        "Debug: no permission defined: .github/workflows/unit_tests.yml:1"
      "score": 0,
      "reason": "non read-only tokens detected in GitHub workflows",
      "name": "Token-Permissions",
      "documentation": {
        "url": "https://github.com/ossf/scorecard/blob/8da30e63afbc62e25c2c1252003aed9d34c3d04d/docs/checks.md#token-permissions",
        "short": "Determines if the project's workflows follow the principle of least privilege."
@evverx evverx added the kind/bug Something isn't working label Nov 13, 2021
@evverx
Copy link
Contributor Author

evverx commented Nov 14, 2021

Apparently actually scorecard doesn't complain about labeler (even though I think it should because scorecard doesn't know what labeler is (as opposed to codeql) and the write permissions are explicitly specified there at the top level). I'll try to open another issue.

Regarding codeql I'm going to fix it with the following patch:

Author: Evgeny Vereshchagin <evvers@ya.ru>
Date:   Sun Nov 14 09:41:42 2021 +0000

    ci: tighten codeql and labeler even more

    by moving the read permissions to the top level and
    granting additional permissions to the specific jobs.
    It should help to prevent new jobs that could be added
    there eventually from having write access to resources they
    most likely would never need.

diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index c003cc5179..460002eaeb 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -11,6 +11,9 @@ on:
   schedule:
     - cron: '0 1 * * *'

+permissions:
+  contents: read
+
 jobs:
   analyze:
     name: Analyze
@@ -20,7 +23,6 @@ jobs:
       cancel-in-progress: true
     permissions:
       actions: read
-      contents: read
       security-events: write

     strategy:
diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml
index 800f8877a3..34d9d63d42 100644
--- a/.github/workflows/labeler.yml
+++ b/.github/workflows/labeler.yml
@@ -9,11 +9,12 @@ on:

 permissions:
   contents: read
-  pull-requests: write

 jobs:
   triage:
     runs-on: ubuntu-latest
+    permissions:
+      pull-requests: write
     steps:
     - uses: actions/labeler@69da01b8e0929f147b8943611bee75ee4175a49e
       with:

but I wouldn't expect everybody to change their actions (that most likely were borrowed from the official documentation) to please scorecard. I think scorecard should support permission granted to specific jobs without top level settings as well

@evverx
Copy link
Contributor Author

evverx commented Nov 14, 2021

Anyway, on an unrelated note, somehow systemd and a project maintained by exactly one person pushing commits directly to the master branch with no PRs, protected branches, reviews, tests and fuzz targets whatsoever keep receiving approximately the same "global" score from scorecard (probably due to inconclusive checks). I think I'm about to give up :-)

@laurentsimon
Copy link
Contributor

Thanks for the report and the time you're investing in this. Don't give up, I'll help you out. Just tell me what you expect and I'll tell you why it's happening and we'll try to improve things, whether it's documentation, logging or result computation

@laurentsimon
Copy link
Contributor

laurentsimon commented Nov 15, 2021

Apparently actually scorecard doesn't complain about labeler (even though I think it should because scorecard doesn't know what labeler is (as opposed to codeql) and the write permissions are explicitly specified there at the top level). I'll try to open another issue.

is this related to #1100?

Regarding codeql I'm going to fix it with the following patch:

Author: Evgeny Vereshchagin <evvers@ya.ru>
Date:   Sun Nov 14 09:41:42 2021 +0000

    ci: tighten codeql and labeler even more

    by moving the read permissions to the top level and
    granting additional permissions to the specific jobs.
    It should help to prevent new jobs that could be added
    there eventually from having write access to resources they
    most likely would never need.

I agree with the reasoning. It's better to have a fail-safe that fail-open solution.

but I wouldn't expect everybody to change their actions (that most likely were borrowed from the official documentation) to please scorecard. I think scorecard should support permission granted to specific jobs without top level settings as well

I see your point. @josepalafox @jhutchings1 would you be open to updating the workflow examples and GitHub documentation in general to nudge users towards defining the top-level permissions:read-only or permissions:? I think it's accepted that default read permissions are better (change the default “read and write” permissions to read-only" - https://securitylab.github.com/research/github-actions-building-blocks/). The problem is that it encourages users to do that behind a "curtain" (settings): it does not benefit from the branch protection (e.g. 2LGTM), it's not not part of the commit history (hard to determine the security settings at a point in the past), hard for a human to read this information from a repo. Config-as-code would be awesome to solve these problems in the long-term. Short-term, nudging users into using config-as-code in code snippets would be beneficial. wdut?

@evverx
Copy link
Contributor Author

evverx commented Nov 15, 2021

is this related to #1100?

@laurentsimon I'm not sure it is. When I opened the issue the systemd project had

permissions:
  contents: read
  pull-requests: write

at the top level of the labeler action. scorecard said that

        "Info: 'contents' permission set to 'read': .github/workflows/labeler.yml:1",
        "Debug: 'pull-requests' permission set to 'write': .github/workflows/labeler.yml:1",
        "Debug: not a publishing workflow: .github/workflows/labeler.yml:1",
        "Debug: not a codeql workflow: .github/workflows/labeler.yml:1",
        "Debug: not a codeql upload SARIF workflow: .github/workflows/labeler.yml:1",

and didn't even warn that there was an action with write permissions.

@evverx
Copy link
Contributor Author

evverx commented Nov 15, 2021

The "codeql" part of this issue seems to be the same as #1100 though. Closing.

@evverx evverx closed this as completed Nov 15, 2021
@laurentsimon
Copy link
Contributor

laurentsimon commented Nov 15, 2021

is this related to #1100?

@laurentsimon I'm not sure it is. When I opened the issue the systemd project had

so I think it was: the workflow are not job-aware yet. Thanks for confirming.

permissions:
  contents: read
  pull-requests: write

at the top level of the labeler action. scorecard said that

        "Info: 'contents' permission set to 'read': .github/workflows/labeler.yml:1",
        "Debug: 'pull-requests' permission set to 'write': .github/workflows/labeler.yml:1",
        "Debug: not a publishing workflow: .github/workflows/labeler.yml:1",
        "Debug: not a codeql workflow: .github/workflows/labeler.yml:1",
        "Debug: not a codeql upload SARIF workflow: .github/workflows/labeler.yml:1",

and didn't even warn that there was an action with write permissions.

Got it. It's listed as Debug instead of Warn. It was an intentional omission because 1) this is low risk and 2) it's acceptable in most cases (i.e., devs use it for static analysis results). So we did not want to confuse developpers because it is not "fixable", i.e. the permission is needed to run the static analyzer.
Do you think it'd be better to make it a Warn?

@laurentsimon laurentsimon reopened this Nov 15, 2021
@evverx
Copy link
Contributor Author

evverx commented Nov 15, 2021

So we did not want to confuse developpers because it is not "fixable", i.e. the permission is needed to run the static analyzer.

@laurentsimon I agree scorecard shouldn't complain about codeql but those write permissions came from https://github.com/marketplace/actions/labeler (which apart from the write permissions uses pull_request_target). What I was trying to say is that I think by default write access should be at least suspicious if actions using them aren't well known like codeql or labeler.

I apologize for the confusion. I should have opened a separate issue about labeler.

@laurentsimon
Copy link
Contributor

laurentsimon commented Nov 15, 2021

So we did not want to confuse developpers because it is not "fixable", i.e. the permission is needed to run the static analyzer.

@laurentsimon I agree scorecard shouldn't complain about codeql but those write permissions came from https://github.com/marketplace/actions/labeler (which apart from the write permissions uses pull_request_target). What I was trying to say is that I think by default write access should be at least suspicious if actions using them aren't well known like codeql or labeler.

Good point. We'd like to do that better. Today, we don't Warn if contents:write/packages is used by a "known" release workflow, for example. But it's harder for us to do that for well-known actions because we don't know all of them: which do you think we should consider acceptable?

We're hoping to leave this decision to users of scorecard, by providing our results in github.com/ossf/allstar and by providing raw results in the future: we hope raw results will be easier to act upon, e.g. thru a policy language.

On a related note: we have a larger plan to cover dangerous workflows in #426 (comment). We added the pull_request_workflow + ref part in this 1050b1c which was merged a few hours ago. You can test it out using ENABLE_DANGEROUS_WORKFLOW=1 as env variable.

Please don't hesitate to add ideas to the tracking issue #426 (comment). Suggestions and feedback are greatly appreciated.

I apologize for the confusion. I should have opened a separate issue about labeler.

no worries.

@evverx
Copy link
Contributor Author

evverx commented Nov 16, 2021

it's harder for us to do that for well-known actions because we don't know all of them: which do you think we should consider acceptable?

I think by analogy with the list of well-know CI services in the CI-Test check new well-known actions could be added on a case-by-case basis. I haven't used any other actions with write permissions apart from codeql and labeler so I'd just add labeler to the list.

We're hoping to leave this decision to users of scorecard, by providing our results in github.com/ossf/allstar a

The problem with this approach is that as far as I understand I could theoretically configure scorecards via allstars all I want locally but as we discussed elsewhere users would still open "issues" based on raw scorecard results that most likely wouldn't be based on any project-specific changes I made. I'd add that having looked at allstars and issues it has reported personally I wouldn't consider using it. It's just absolutely unwarranted bureaucracy with phrases like "achieve compliance" in the documentation. I understand where it's coming from and have no problem with it in certain places (usually far from GitHub) :-) I think I'll just keep extracting the results of "raw" scorecard checks I find useful and act on them.

You can test it out using ENABLE_DANGEROUS_WORKFLOW=1 as env variable

I tried it out with the systemd repository and it failed with "internal error: invalid GitHub workflow" as far as I can see

  "date": "2021-11-15",
  "repo": {
    "name": "github.com/systemd/systemd",
    "commit": "947796eac385651f6a66fc0ce925a301b49f6fa4"
  },
  "score": -1.0,
  "checks": [
    {
      "details": null,
      "score": -1,
      "reason": "internal error: invalid GitHub workflow",
      "name": "Dangerous-Workflow",
...
    }

@laurentsimon
Copy link
Contributor

laurentsimon commented Nov 16, 2021

it's harder for us to do that for well-known actions because we don't know all of them: which do you think we should consider acceptable?

I think by analogy with the list of well-know CI services in the CI-Test check new well-known actions could be added on a case-by-case basis. I haven't used any other actions with write permissions apart from codeql and labeler so I'd just add labeler to the list.

Thanks, we can do that. Can you create an issue for it? That should be pretty easy to implement.

We're hoping to leave this decision to users of scorecard, by providing our results in github.com/ossf/allstar a

The problem with this approach is that as far as I understand I could theoretically configure scorecards via allstars all I want locally but as we discussed elsewhere users would still open "issues" based on raw scorecard results that most likely wouldn't be based on any project-specific changes I made.

what do you mean?

I'd add that having looked at allstars and issues it has reported personally I wouldn't consider using it. It's just absolutely unwarranted bureaucracy with phrases like "achieve compliance" in the documentation.

It's more geared towards orgs that have many repos.

I understand where it's coming from and have no problem with it in certain places (usually far from GitHub) :-) I think I'll just keep extracting the results of "raw" scorecard checks I find useful and act on them.

in a couple weeks, we'll have a beta version of scorecard -as-GitHub-action. If you're willing to give it a try, it'd be awesome.

You can test it out using ENABLE_DANGEROUS_WORKFLOW=1 as env variable

I tried it out with the systemd repository and it failed with "internal error: invalid GitHub workflow" as far as I can see

  "date": "2021-11-15",
  "repo": {
    "name": "github.com/systemd/systemd",
    "commit": "947796eac385651f6a66fc0ce925a301b49f6fa4"
  },
  "score": -1.0,
  "checks": [
    {
      "details": null,
      "score": -1,
      "reason": "internal error: invalid GitHub workflow",
      "name": "Dangerous-Workflow",
...
    }

We're currently updating all our checks to using github.com/rhysd/actionlint, so I think we'll be able to fix this problem very soon. @asraa @chrismcgehee FYI

@asraa
Copy link
Contributor

asraa commented Nov 16, 2021

I tried it out with the systemd repository and it failed with "internal error: invalid GitHub workflow" as far as I can see

I'll update the dangerous-workflow check with the workflow parser and make sure it passes this test. Thank you so much for pointing out these behaviors.

@evverx
Copy link
Contributor Author

evverx commented Nov 16, 2021

what do you mean?

I think I need to reread the allstar documentation to be more specific. It could be I misunderstood how it's configured on top of scorecard, which it uses under the hood as far as I understand.

in a couple weeks, we'll have a beta version of scorecard -as-GitHub-action

Looking at #1074, it seems the action is supposed to send data to the "code-scanning" tab of repositories (by analogy with codeql I assume). I'm not sure I like this approach because it kind of makes it hard for external contributors who don't have access to that tab to be able to see issues to try to fix them. Basically, they have to fork repositories, wait for the cron job (or whatever else updates that tab) and keep track of those issues by constantly updating their forks. And they can't see issues marked as "false positives" in upstream projects for example so they might send PRs only to discover that they would be rejected.

@laurentsimon
Copy link
Contributor

the action is aimed at repo owners, to help them run scorecard continuously without the pain of installing the tool. We'd like to extend it to be more usable for consumers... but for now we only support the BigQuery table. We have floated around the idea of REST API as well.

@evverx
Copy link
Contributor Author

evverx commented Nov 16, 2021

@laurentsimon I think issues actions like that report should be fixed eventually and it usually helps when more people have access to various dashboards. I'm not saying it's an issue related to the scorecard action specifically. It's just that that "code scanning" tab hides alerts from everybody apart from repo owners (which probably makes sense considering the nature of the tab) while at the same time all those alerts pop up on forks if they get updated more or less regularly so it isn't clear (to me at least) why that tab is hidden in the first place.

@josepalafox
Copy link

I will double check but I believe when you fork a repo it does keep the action configuration, but it has to be manually triggered, it doesn't run by default when the project is forked. This is in effect the fork-er re-running the scanner rather than the same scan results being replicated. It wouldn't carry over suppressed alerts or the alert history with it either, I don't think. The small difference here is anyone could fork anything and run scorecard or any other SAST tool against it. I don't know if that helps the discussion but figured I'd just toss in a note for clarification.

@evverx
Copy link
Contributor Author

evverx commented Nov 16, 2021

The small difference here is anyone could fork anything and run scorecard or any other SAST tool against it

And that's probably what motivated contributors would do. But I doubt "drive-by" contributors would want to go that far to just look at alerts they could potentially fix so they just go elsewhere.

FWIW judging by #1074 (comment) the scorecard project has already run into something like that

@evverx
Copy link
Contributor Author

evverx commented Nov 16, 2021

Forgot to mention that also it doesn't seem to be possible to refer to those alerts in the commit messages because unlike, for example, links to OSS-Fuzz issues that are opened to the public eventually, all links to the security tab seem to always point to 404 for everybody except for repo owners.

@laurentsimon
Copy link
Contributor

@laurentsimon I think issues actions like that report should be fixed eventually and it usually helps when more people have access to various dashboards. I'm not saying it's an issue related to the scorecard action specifically. It's just that that "code scanning" tab hides alerts from everybody apart from repo owners (which probably makes sense considering the nature of the tab) while at the same time all those alerts pop up on forks if they get updated more or less regularly so it isn't clear (to me at least) why that tab is hidden in the first place.

I agree public dashboard would be a plus, this is an idea we've been tossing around. GitHub could have an option for devs to opt-in in order to share their dashboard, for example. Like you say, someone can run dependabot on a fork repo and dependenbot for security alerts. Doing this at scale for everyone is a little more challenging :-)

@laurentsimon
Copy link
Contributor

I will double check but I believe when you fork a repo it does keep the action configuration, but it has to be manually triggered, it doesn't run by default when the project is forked. This is in effect the fork-er re-running the scanner rather than the same scan results being replicated. It wouldn't carry over suppressed alerts or the alert history with it either, I don't think. The small difference here is anyone could fork anything and run scorecard or any other SAST tool against it. I don't know if that helps the discussion but figured I'd just toss in a note for clarification.

Thanks for the info @josepalafox !

@evverx
Copy link
Contributor Author

evverx commented Nov 16, 2021

I will double check but I believe when you fork a repo it does keep the action configuration, but it has to be manually triggered, it doesn't run by default when the project is forked.

@josepalafox I might be wrong but looking at systemd/systemd#21343 I think that's how Dependabot is supposed to work (in theory at least). GitHub Actions sending data to security scanning tabs are run automatically according to their configs.

@josepalafox
Copy link

I think the workflow you're looking for will be resolved in future updates to the platform and looks to be in beta now I believe: github/roadmap#332

Re:dependabot I think runs differently because it is a vendored action.

@evverx
Copy link
Contributor Author

evverx commented Nov 23, 2021

looking at systemd/systemd#21343 I think that's how Dependabot is supposed to work (in theory at least)

@laurentsimon FWIW I don't think scorecard should recommend using Dependabot until the issue mentioned at systemd/systemd#21343 is fixed. Apparenlty it annoys people maintaining stable forks very much and they can't just remove and recreate those forks.

@evverx
Copy link
Contributor Author

evverx commented Nov 23, 2021

I've just opened #1336 where I mentioned what Dependabot brings with it.

@evverx
Copy link
Contributor Author

evverx commented Nov 23, 2021

To be fair though, other than that I think it's better than alternatives. RenovateBot creates PRs like evverx/systemd#30 that are apparently targeted at robots who can figure out what SHAs correspond to by just looking at them

@evverx
Copy link
Contributor Author

evverx commented Dec 23, 2021

As far as I understand all "corner" cases should be addressed by config files by analogy with the binary-artifacts check: #1256 (comment). Closing this one.

@evverx evverx closed this as completed Dec 23, 2021
@laurentsimon laurentsimon reopened this Dec 24, 2021
@laurentsimon
Copy link
Contributor

laurentsimon commented Dec 24, 2021

@evverx just be sure: is there still a problem with labeler? Anything we can to to improve the results while we're working on the config files/policy?
fyi, we've merged this #1356 since then. scorecard may complain about undefined top-level permissions but will only reduce 1 point if the jobs have their permissions defined. That logic is applied for each job, if memory serves :-)

@evverx
Copy link
Contributor Author

evverx commented Dec 24, 2021

Sorry. I wrote that comment semi-automatically. To judge from

        "Debug: run level 'pull-requests' permission set to 'write': .github/workflows/labeler.yml:17",
        "Info: top level 'contents' permission set to 'read': .github/workflows/linter.yml:14",

it should be fixed once #1100 is closed. And when that happens as far as I understand it should be possible to use config files to prevent scorecard from complaining about it.

Anything we can to to improve the results while we're working on the config files/policy?

I have to admit I'm not sure I like the idea of moving everything to config files because I think scorecard should be clever enough to handle most corner cases by default. But as far as I can tell "consumers" are willing to do that and as long as they don't try to push them upstream or ask maintainers to write those configs for them I think it should be fine. Just to clarify, I'm not saying there is anything wrong with config files. It's just that I don't think I'm a "consumer" in that particular sense.

@laurentsimon
Copy link
Contributor

laurentsimon commented Dec 28, 2021

Sorry. I wrote that comment semi-automatically. To judge from

        "Debug: run level 'pull-requests' permission set to 'write': .github/workflows/labeler.yml:17",
        "Info: top level 'contents' permission set to 'read': .github/workflows/linter.yml:14",

it should be fixed once #1100 is closed. And when that happens as far as I understand it should be possible to use config files to prevent scorecard from complaining about it.

I actually think this issue has been addressed. The code now parses the GitHub action instead of using a simple regex. @chrismcgehee can we close this issue?
The Debug message above does not reduce the score, it's only a debug message. The Warn messages indicates something that a user may address, but not debug messages. The reasoning is that we expect most users to not use the verbosity Debug flag.
We don't consider pull-requests as a permission of interest because it has many false positives, see #1359. Ideally we should consider it of interest... Feel free to comment on the issue #1359. This is something we may expose in raw results and let the policy decide whether it's OK...

Anything we can to to improve the results while we're working on the config files/policy?

I have to admit I'm not sure I like the idea of moving everything to config files because I think scorecard should be clever enough to handle most corner cases by default. But as far as I can tell "consumers" are willing to do that and as long as they don't try to push them upstream or ask maintainers to write those configs for them I think it should be fine. Just to clarify, I'm not saying there is anything wrong with config files. It's just that I don't think I'm a "consumer" in that particular sense.

just FYI, we'll be exposing a default policy file, which I think is where scorecard should be clever enough to handle most corner cases by default will be addressed. And we can refine this policy file given community feedback over time.

wdut?

@evverx
Copy link
Contributor Author

evverx commented Dec 28, 2021

The Debug message above does not reduce the score, it's only a debug message. The Warn messages indicates something that a user may address, but not debug messages. The reasoning is that we expect most users to not use the verbosity Debug flag.

I think what I was trying to say is that scorecard should complain about it somehow to let people decided whether actions like that should be kept or not. Initially I singled out labeler because at the time "pull_request_target" was used there without any restrictions. Since I didn't think it was useful enough to warrant that I was going to throw it away but was outvoted :-) because it turns out those labels are actually used to categorize issues and so on. Eventually I added pull-requests: write there to limit the scope at least. Anyway, it seems this should be handled by the Dangerous workflow check probably and the token permission check works as expected.

just FYI, we'll be exposing a default policy file, which I think is where scorecard should be clever enough to handle most corner cases by default will be addressed. And we can refine this policy file given community feedback over time.
wdut?

It's better than just "raw" results but I'm not sure how those default policies would be shipped. If they aren't included in scorecard out of the box they should be kept somewhere and passed additionally to it and it makes it kind of hard to actually use them.

@laurentsimon
Copy link
Contributor

laurentsimon commented Dec 28, 2021

The Debug message above does not reduce the score, it's only a debug message. The Warn messages indicates something that a user may address, but not debug messages. The reasoning is that we expect most users to not use the verbosity Debug flag.

I think what I was trying to say is that scorecard should complain about it somehow to let people decided whether actions like that should be kept or not. Initially I singled out labeler because at the time "pull_request_target" was used there without any restrictions. Since I didn't think it was useful enough to warrant that I was going to throw it away but was outvoted :-) because it turns out those labels are actually used to categorize issues and so on. Eventually I added pull-requests: write there to limit the scope at least. Anyway, it seems this should be handled by the Dangerous workflow check probably and the token permission check works as expected.

This should be doable with the raw results. Users will be able to tweak the default policy to add additional rules without becoming experts in the policy language.

just FYI, we'll be exposing a default policy file, which I think is where scorecard should be clever enough to handle most corner cases by default will be addressed. And we can refine this policy file given community feedback over time.
wdut?

It's better than just "raw" results but I'm not sure how those default policies would be shipped. If they aren't included in scorecard out of the box they should be kept somewhere and passed additionally to it and it makes it kind of hard to actually use them.

the default policy will be shipped within scorecard and used by default. For example --policy default or something along these lines. The raw results can be seen as an intermediate results for users to fiddle with, but we'll provide a default policy, like we do for scoring today. That's the current plan. Let me know if you have thought of concerns.

@evverx
Copy link
Contributor Author

evverx commented Dec 28, 2021

The raw results can be seen as an intermediate results for users to fiddle with, but we'll provide a default policy, like we do for scoring today. That's the current plan.

I think as long as the default policy is supposed to cover most corner cases it should be fine (and probably it doesn't even matter how it's implemented). It's just that I was initially under the impression that it was targeted at people somewhat specializing in writing those policies and personally I wouldn't want to do that because it would be one more thing to maintain and keep up to date.

@evverx
Copy link
Contributor Author

evverx commented Dec 28, 2021

FWIW @laurentsimon I think this issue can be closed. I'd go ahead and close it but since it was already reopened once I'm not sure if there is anything else that should be addressed here

@laurentsimon
Copy link
Contributor

The raw results can be seen as an intermediate results for users to fiddle with, but we'll provide a default policy, like we do for scoring today. That's the current plan.

I think as long as the default policy is supposed to cover most corner cases it should be fine (and probably it doesn't even matter how it's implemented). It's just that I was initially under the impression that it was targeted at people somewhat specializing in writing those policies and personally I wouldn't want to do that because it would be one more thing to maintain and keep up to date.

it's just to allow use cases where users want a different policy from the default one. Today, the score is too coarse to allow for fine-grained policy, which is why we want to expose "raw" results. But we wont force users to write these policies, we'll have a default one.

@evverx
Copy link
Contributor Author

evverx commented Dec 29, 2021

it's just to allow use cases where users want a different policy from the default one

The problem is that power users like that are usually best equipped to improve default policies. If it's much easier for them to keep their changes "downstream" they usually do just that. I mean, for example, it's hard to deal with selinux policies so people just have to report their issues upstream and the default policy gets better :-)

But we wont force users to write these policies, we'll have a default one.

Good to know. Thanks!

@laurentsimon
Copy link
Contributor

it's just to allow use cases where users want a different policy from the default one

The problem is that power users like that are usually best equipped to improve default policies. If it's much easier for them to keep their changes "downstream" they usually do just that. I mean, for example, it's hard to deal with selinux policies so people just have to report their issues upstream and the default policy gets better :-)

I agree we want power users to help us make the default policies better. But there are cases when different companies/teams view things differently about what's appropriate or not. Policies will allow them to do what they want.

But we wont force users to write these policies, we'll have a default one.

Good to know. Thanks!

@evverx
Copy link
Contributor Author

evverx commented Dec 30, 2021

But there are cases when different companies/teams view things differently about what's appropriate or not. Policies will allow them to do what they want.

Can't argue with that but given that I've never seen anyone from those companies asking for anything here on GitHub publicly (or even discussing it) I can only speculate (while I'm pretty sure there are specific use cases that those policies should cater to). Anyway, not that it matters, but all things considered I agree that (unlike some decisions that I completely disagree with) those policies are useful. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants