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

Implement Actions extractor and placeholder Actions QL packs #17850

Merged
merged 7 commits into from
Oct 28, 2024

Conversation

dbartol
Copy link
Contributor

@dbartol dbartol commented Oct 25, 2024

The PR implements an extractor for GitHub Actions workflows. The extractor more or less just forwards to the JavaScript extractor to do the actual extraction. The JavaScript extractor handles both JS and YAML. For now, we're only using the YAML, but we have ambitions to analyze JS code embedded within a workflow in the future. The autobuild.* scripts copy all of the CODEQL_EXTRACTOR_ACTIONS_* environment variables into the CODEQL_EXTRACTOR_JAVASCRIPT_* variables for the JavaScript extractor. In addition, if no path filters are specified by the user, we supply a default set of path filters the extractor only YAML files that are likely to be Actions workflows or reusable Actions.

In addition to the extractor itself, I've added placeholder CodeQL packs for the library, queries, and tests. There are two placeholder tests: one that imports a .qll file from the library pack, and one that runs a query from the query pack. Note that the library pack does not have a dbscheme. Instead, it depends on codeql/javascript-all, since the actual extraction is done by the JavaScript extractor with the JavaScript dbscheme. The extractor: actions property on the query pack ensures that the queries are treated as being for the actions language, rather than the javascript language.

Note to reviewers: I know nothing about Bash except what I've Googled in the last few hours. Please take a close look at the autobuild.sh script.

A subsequent PR will add Bazel files to incorporate the new extractor into the CLI build.

actions/ql/src/Placeholder.ql Fixed Show fixed Hide fixed
actions/ql/src/Placeholder.ql Fixed Show fixed Hide fixed
@dbartol dbartol requested a review from RasmusWL October 25, 2024 21:57
@dbartol dbartol added Actions Analysis of GitHub Actions enhancement New feature or request no-change-note-required This PR does not need a change note labels Oct 25, 2024
@dbartol
Copy link
Contributor Author

dbartol commented Oct 25, 2024

@pwntester

@RasmusWL
Copy link
Member

Since I had the code checked out to fix the formatting, I took the liberty of adding auto-labeler support as well 😊

RasmusWL
RasmusWL previously approved these changes Oct 28, 2024
Copy link
Member

@RasmusWL RasmusWL left a comment

Choose a reason for hiding this comment

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

This looks plausible to me 👍 I did a quick grep of uses of CODEQL_EXTRACTOR_JAVASCRIPT_* env vars and I didn't spot anything missing.

Bash parts LGTM 👍 (just a minor nitpick)

actions/extractor/tools/autobuild.sh Outdated Show resolved Hide resolved
Co-authored-by: Rasmus Wriedt Larsen <[email protected]>
@dbartol dbartol merged commit a70ce25 into main Oct 28, 2024
11 checks passed
@dbartol dbartol deleted the dbartol/actions-placeholder branch October 28, 2024 15:34
Copy link
Contributor

@aibaars aibaars left a comment

Choose a reason for hiding this comment

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

I think the change to be bash script may cause problems if the environment variables are uninitialised. Did you test the change?

@dbartol dbartol restored the dbartol/actions-placeholder branch October 28, 2024 15:34
@dbartol
Copy link
Contributor Author

dbartol commented Oct 28, 2024

I think the change to be bash script may cause problems if the environment variables are uninitialised. Did you test the change?

I'll give them a try locally. I'm planning integration tests once everything is hooked up into the CLI build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Actions Analysis of GitHub Actions enhancement New feature or request no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants