Skip to content

Conversation

@robertbrignull
Copy link
Contributor

Since some of the code now needs to run flawlessly outside of actions, I think a CodeQL query will be really helpful for spotting accidental uses.

This borrows a lot of the framework from undeclared-action-input.ql but adds in checks for guards that we are running in actions/cli mode.

This finds a few cases, which I've fixed in this PR. I've pushed a branch without the fixes too so you can see what the alerts were at https://github.com/github/codeql-action/security/code-scanning?query=ref%3Arefs%2Fheads%2Faction_libs_query_alerts

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.

Copy link
Contributor

@chrisgavin chrisgavin left a comment

Choose a reason for hiding this comment

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

I don't think it's essential to resolve now, but just to check my understanding, am I right in thinking that so long as a use of an Actions library is guarded on one call path, it will be considered guarded on all of them?

Might make sense to add a global logger at some point so we don't have to pass it around.

@robertbrignull
Copy link
Contributor Author

am I right in thinking that so long as a use of an Actions library is guarded on one call path, it will be considered guarded on all of them?

Partially. You're right it only checks for the existance of one guard instead of making sure that all paths are covered, however we're also looking at individual InvokeExpr or inner functions, so I think in the vast majority of cases there will only be one path and it'll be correct.
Also unfortunately doing it the other way of making sure all paths are covered always seems to end up being very hard to express and compute. It's generally not worked for me in the past when I've tried it. I always wish there were a proper library like dataflow but for execution flow. Using the control flow graph directly never works well for me.

@robertbrignull
Copy link
Contributor Author

Might make sense to add a global logger at some point so we don't have to pass it around.

Makes sense to me. I think it should work ok too as we can make a very good guess of whether we're in actions mode or CLI mode by looking at the env vars, so we should be able to create a logged of the right type on demand.

@robertbrignull robertbrignull merged commit 1f5a571 into main Aug 21, 2020
@robertbrignull robertbrignull deleted the action_libs_query branch August 21, 2020 09:31
@github-actions github-actions bot mentioned this pull request Aug 24, 2020
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.

3 participants