| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Neat! I defer to Robert on whether the mode initialisations are in the right place, but the logic looks sensible to me.
Sorry, something went wrong.
|
The conditional branching within the updated getCodeQLBundleDownloadURL function should be tested based on the new method of determining the mode. Every occurrence in which an explicit mode was passed in now implicitly relies upon the environment in which it is called. Should that implicit behavior be moved to a higher level of abstraction, e.g., into functions directly consumed by the end-user? There are some low-level functions that rely on the results of getCodeQLBundleDownloadURL. |
Sorry, something went wrong.
|
Thanks for the comment @RA80533. I added a couple of more unit tests. I feel like the code is reasonably safe now. We are sure to set the mode at the beginning of every entry point. If there is a call to get the mode and it hasn't been set yet, then that will fail. In some ways, the logic is more complex because some low level functions now rely on a new environment variable, but the trade off is that we no longer need to pass the mode parameter around. I had originally tried keeping the mode parameter and passing it around, but then almost every function needed access to it. Using the environment variable in a single place seems like a reasonable trade-off. There are other parts of the code that also rely on environment variables, so this situation is not too different. |
Sorry, something went wrong.
It is very much a case of deciding which to trade off. Environment variables become unwieldy in larger projects because they create a mathematical side effect in the flow of logic; for smaller projects, such as this one, the flow of data is easy enough to follow to the point that such dependent behavior is easy to track down. /lgtm |
Sorry, something went wrong.
|
Ooooh...code scanning found a bug. Thank you code scanning. |
Sorry, something went wrong.
| export function setMode(mode: Mode) { | ||
| // avoid accessing actions core when in runner mode | ||
| if (mode === Mode.actions) { | ||
| core.exportVariable(CODEQL_RUN_MODE_ENV_VAR, mode); |
There was a problem hiding this comment.
Note this is a code scanning error, but a false positive. We cannot have a code path accessible from the runner that will call into the core library. The if clause above prevents this from happening.
Sorry, something went wrong.
|
Updated ql queries that look for runner/actions access. Could I get another look at this? |
Sorry, something went wrong.
|
Without the guard, what would be available to non-Actions runners through the core library? EDIT: Oh, I see. The code library doesn’t support non-GitHub Actions environments. |
Sorry, something went wrong.
|
Yes, mostly right...there are some actions libraries that are ok to use for the runner. codeql-action/queries/unguarded-action-lib.ql Lines 16 to 21 in 3a474e8 |
Sorry, something went wrong.
There was a problem hiding this comment.
Nice. Logic makes sense and neat adjustment to the query; a few minor suggestions there.
There's probably room to combine more of the logic in that query, and use some builtin features of the CodeQL JS libraries, but we can do that separately. No need to hold up this PR.
Sorry, something went wrong.
| "(Advanced, windows-only) Inject a windows tracer of this process into a parent process <number> levels up." | ||
| ) | ||
| .action(async (cmd: InitArgs) => { | ||
| setMode(Mode.runner); |
There was a problem hiding this comment.
Minor: I wonder if there's a prehook we can use to always set the mode to runner at the start of each action() call in this file. Or we can check it by query, as a follow up.
Sorry, something went wrong.
There was a problem hiding this comment.
Hmmm...it looks like there is an event mechanism for commander, but it's not quite what we need and it is internal, so I think we will need to create a query here.
Sorry, something went wrong.
| /** | ||
| * Get an expr that is only executed on actions | ||
| */ | ||
| abstract Expr getAnActionsExpr(); |
There was a problem hiding this comment.
You could instead declare:
abstract Stmt getActionsBlock();
/**
* Gets an expr that is only executed on actions
*/
final Expr getAnActionsExpr() { getActionsBlock().getAChildStmt*().getAChildExpr*() = result }This way each subclass needs to describe what they consider an Actions-specific statement, and you don't need to repeat the logic for an Actions-specific expression.
Sorry, something went wrong.
There was a problem hiding this comment.
Yes. That's better. Thanks.
Sorry, something went wrong.
This commit changes the way the action determines if running in action or runner mode. There is now an environment variable that is set at the beginning of the process and elsewhere in the process, we can check to see if the variable is set.
Update the ql queries to account for change in how we look for runner Previously, we guarded blocks of code to be run by the runner or the action using if statements like this: ```js if (mode === "actions") ... ``` We are no longer doing this. And now, the `unguarded-action-lib.ql` query is out of date. This query checks that runner code does not unintentionally access actions-only methods in the libraries. With these changes, we now ensure that code scanning is happy.
|
Wait...commander v8 is soon to be released with a hook for preAction and postAction in it. I will get this merged, and then do the update for v8. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
The initial goal of this change is to send more complete information to code scanning via the user agent. This also opens the possibility of sending the action/runner version to the CLI.
This commit changes the way the action determines if running in action
or runner mode. There is now an environment variable that is set at the
beginning of the process and elsewhere in the process, we can check to
see if the variable is set.
Merge / deployment checklist