Skip to content

Conversation

@KyFaSt
Copy link
Contributor

@KyFaSt KyFaSt commented Jan 16, 2025

Pull Request checklist

Add a map to suggest the minimum permissions needed for the GITHUB_TOKEN when commonly used GitHub owned actions are detected

All query authors

Internal query authors only

  • Autofixes generated based on these changes are valid, only needed if this PR makes significant changes to .ql, .qll, or .qhelp files. See the documentation (internal access required).
  • Changes are validated at scale (internal access required).
  • Adding a new query? Consider also adding the query to autofix.

* detect commonly used GitHub owned actions use a map to suggest the
  minimum permissions needed for the GITHUB_TOKEN
@github-actions github-actions bot added the Actions Analysis of GitHub Actions label Jan 16, 2025
@KyFaSt
Copy link
Contributor Author

KyFaSt commented Jan 16, 2025

Hi @dave-bartolomeo here's the draft we discussed

// using the data extension or there are no uses steps
// that are children of the job
boolean unknownPermissions(Job job) {
minPermissions(job) = "" and result = true or count(job.getAChildNode*().(MinimumActionsPermissions)) = 0 and result = true

Check warning

Code scanning / CodeQL

Counting zero elements Warning

Use not exists(..) instead of checking that there is zero elements in a set.
not e.getName() = "workflow_call"
)
select job,
"Actions Job or Workflow does not set permissions. Recommended minimum permissions are ($@)",

Check warning

Code scanning / CodeQL

Alert message style violation Warning

Alert message should end with a full stop.
)
select job,
"Actions Job or Workflow does not set permissions. Recommended minimum permissions are ($@)",
job, getMinPermissions(job)

Check warning

Code scanning / CodeQL

Alert message style violation Warning

Don't repeat the alert location as a link.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Actions Analysis of GitHub Actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant