| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Adds a new org-managed repository property (github-codeql-tools) that can supply a default tools input value (when the workflow doesn’t set one), enabling organizations to opt into using the toolcache without per-run CLI downloads.
Changes:
Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file| File | Description |
|---|---|
| src/feature-flags/properties.ts | Adds the new repository property name and parser typing for github-codeql-tools. |
| src/feature-flags/properties.test.ts | Tests loading/parsing of the new github-codeql-tools property. |
| src/init-action.ts | Resolves effective tools input (workflow vs repository property) and passes origin flag into initCodeQL. |
| src/init.ts | Threads toolsInputFromRepositoryProperty into setupCodeQL. |
| src/codeql.ts | Threads toolsInputFromRepositoryProperty into setupCodeQLBundle. |
| src/setup-codeql.ts | Adds toolsInputFromRepositoryProperty parameter and uses it to allow toolcache without FF/dynamic checks. |
| src/setup-codeql.test.ts | Adds tests for toolcache behavior when enabled via repository property (including empty toolcache fallback). |
| lib/* | Generated JS output corresponding to the TS changes (not reviewed). |
Sorry, something went wrong.
There was a problem hiding this comment.
This PR needs work. As CCR has already identified, the new logic is not coherently applied to all parts of the CodeQL Action.
Beyond that, we have some high-level design questions to answer before settling on an implementation. I have discussed these in my details comments, but in summary they are:
Once we have decided on all these aspects, then we should also add a changelog entry here and update the public docs for the new property.
Sorry, something went wrong.
| // Determine the effective tools input. | ||
| // The explicit `tools` workflow input takes precedence. If none is provided, | ||
| // fall back to the 'github-codeql-tools' repository property (if set). | ||
| const toolsWorkflowInput = getOptionalInput("tools"); | ||
| const toolsPropertyValue: string | undefined = | ||
| repositoryPropertiesResult.orElse({})[RepositoryPropertyName.TOOLS]; | ||
| const effectiveToolsInput = toolsWorkflowInput ?? toolsPropertyValue; | ||
| const toolsInputFromRepositoryProperty = | ||
| toolsWorkflowInput === undefined && toolsPropertyValue !== undefined; |
There was a problem hiding this comment.
Let's discuss this offline and more widely in the team.
Sorry, something went wrong.
There was a problem hiding this comment.
as for 2:
That been said , I'm not sure whether we can decide over the semantics of this on our own. @jonjanego is this something Product would have a saying about?
Sorry, something went wrong.
There was a problem hiding this comment.
I don't see this as policy enforcement, in fact i struggle to think on a situation where an enterprise would want to enforce a specific version
That point wasn't necessarily about this specific property, but about our use of repository properties in general. We want all of our repository properties to behave in a coherent way. So if others serve as an enterprise policy enforcement tool (e.g. to force particular queries to run), then this should be consistent for all properties. (Or have a coherent syntax/naming convention for "enforcement" vs "default".)
I think we decided elsewhere that we don't want the repository properties to serve as enforcement tool, since there are other features which are designed for that.
Sorry, something went wrong.
| const allowToolcacheValueFF = await features.getValue( | ||
| Feature.AllowToolcacheInput, | ||
| ); | ||
| const allowToolcacheValue = | ||
| allowToolcacheValueFF && (isDynamicWorkflow() || util.isInTestMode()); | ||
| toolsInputFromRepositoryProperty || | ||
| (allowToolcacheValueFF && (isDynamicWorkflow() || util.isInTestMode())); |
There was a problem hiding this comment.
We will need to rethink this logic:
Sorry, something went wrong.
There was a problem hiding this comment.
Yes, I agree with your observations:
Sorry, something went wrong.
There was a problem hiding this comment.
dynamic workflows are all GitHub-managed workflows. That's mainly Default Setup, but also Code Quality, CSRA, ...
I lean towards this affecting advanced workflows that don't have specific tools input , too
Just to be clear, my point was not that we would want this to affect advanced workflows that don't have a specific tools input, but that the implementation in the PR would have this (potentially undesirable) effect. No tools input is the default that causes the CodeQL Action to determine the latest, stable CLI version that's available, and doesn't mean that it should be overriden. Note also that your 2nd and 3rd point contradict each other.
Ideally, we'd have a way for customers to express whether they want the repo props to apply to all CodeQL workflows, or just Default Setup etc.
For the repo property that controls extra queries, we don't restrict it to just dynamic workflows. So I suppose we should be consistent with tools.
Sorry, something went wrong.
| tarSupportsZstd: boolean, | ||
| features: FeatureEnablement, | ||
| logger: Logger, | ||
| toolsInputFromRepositoryProperty = false, |
There was a problem hiding this comment.
We should consider whether it would be better to set toolsInput to the computed input, instead of having an extra toolsInputFromRepositoryProperty value.
Using only toolsInput would simplify the logic and reduce scope for errors here. (See my other comment about the enablement logic.)
Keeping toolsInputFromRepositoryProperty allows more specific log messages below. However, if we have a log message when computing the tools value that says Settings tools: ${value} based on repository property (or similar), then we wouldn't need to log that in each case here.
Sorry, something went wrong.
There was a problem hiding this comment.
I still think my suggestion to have an early log message about the source of the value when we compute the effective tools value makes more sense than having all the individual log messages state this.
Sorry, something went wrong.
| [`Ignoring 'tools: toolcache' because the feature is not enabled.`], | ||
| ); | ||
|
|
||
| test.serial( |
There was a problem hiding this comment.
The new tests here would not be necessary if we used the existing toolsInput argument.
Sorry, something went wrong.
There was a problem hiding this comment.
Comments on the latest commit.
Sorry, something went wrong.
| * @returns An object containing the effective tools input and whether it came from repository property | ||
| */ | ||
| export function resolveToolsInput( | ||
| repositoryProperties: Record<string, any>, |
There was a problem hiding this comment.
We have a RepositoryProperties type. Why the less precise type here?
Sorry, something went wrong.
There was a problem hiding this comment.
using it creates cyclic dependency
Sorry, something went wrong.
There was a problem hiding this comment.
But this function doesn't have to be in this file - in fact it would probably be better off somewhere else, since it's not primarily an Actions helper
Sorry, something went wrong.
| repositoryPropertiesResult.orElse({})[RepositoryPropertyName.TOOLS]; | ||
| const effectiveToolsInput = toolsWorkflowInput ?? toolsPropertyValue; | ||
| const resolvedToolsInput = resolveToolsInput( | ||
| repositoryPropertiesResult.orElse({}), |
There was a problem hiding this comment.
Move the definition of the repositoryProperties constant up and then use that here instead of repositoryPropertiesResult.orElse({}).
Sorry, something went wrong.
| */ | ||
| export function resolveToolsInput( | ||
| repositoryProperties: Record<string, any>, | ||
| toolsPropertyName: string, |
There was a problem hiding this comment.
Why is this a parameter of this function? It's always RepositoryPropertyName.TOOLS. I can't think of a reason where we'd want this to be something else either.
Sorry, something went wrong.
There was a problem hiding this comment.
again, importing that variable would create a circular dep
Sorry, something went wrong.
| const toolsInputFromRepositoryProperty = | ||
| resolvedToolsInput.toolsInputFromRepositoryProperty; |
There was a problem hiding this comment.
This is only used once, use resolvedToolsInput.toolsInputFromRepositoryProperty directly below?
Sorry, something went wrong.
| logger.warning( | ||
| `Ignoring ${getToolsInputOriginDescription(toolsInput, toolsInputFromRepositoryProperty)} because the feature is not enabled.`, |
There was a problem hiding this comment.
I don't think this should be a warning, since there's not really anything the user can do about it.
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for preparing the new version of this.
I have one major concern about the current implementation of resolveToolsInput since it will make an unnecessary, extra API request. The implementation is also overly complicated and forces the tests to run sequentially. We can simplify that and also improve test performance.
The unit test coverage is comprehensive, but some of the tests essentially test the same thing or test fundamental JavaScript semantics. I am not opposed to exercising all of those cases for completeness, but it is a concern if they all have to run sequentially.
Have you tested that the repository property works as expected in practice, e.g. on a test repository?
Beyond that, I am still slightly concerned that the repository property will apply to all workflows if there is no explicit tools input. (See also this discussion.) We should assume that no explicit tools input is what the vast majority of workflows have currently. So if the repository property is set for an org/repo, it will apply to essentially all workflows. Maybe this is OK if we assumed that each repo will typically only have one CodeQL workflow (consider also that Code Security and Code Quality are separate CodeQL workflows for this purpose) and the repository property is only set for a repository, rather than an organisation (we will want to make that explicit in the documentation).
The PR template rates this as a "high risk" change, so I'd like to think about what we can do to reduce that risk. Particularly, once we have reached a sensible implementation for this, it wouldn't seem difficult to put the use of the repository property in resolveToolsInput behind a FF if we wanted to. Alternatively, we could reassess the risk level based on testing / the test coverage.
The PR template should also include the "Other first-party" workflows.
Sorry, something went wrong.
| ## [UNRELEASED] | ||
|
|
||
| No user facing changes. | ||
| - Organizations can now create a custom repository property with the name `github-codeql-tools` to control the CodeQL CLI tools input at the repository level. When this property is set to a valid tools input value (such as `"toolcache"`, `"latest"`, or a specific version), it will override the default tools configuration for that repository. This allows organization administrators to standardize CodeQL CLI versions across repositories or enable toolcache usage on repositories where it would otherwise be restricted. For more information on creating custom repository properties, see [Managing custom properties for repositories in your organization](https://docs.github.com/en/organizations/managing-organization-settings/managing-custom-properties-for-repositories-in-your-organization). |
There was a problem hiding this comment.
This is quite a lengthy entry. We should update https://docs.github.com/en/code-security/concepts/code-scanning/repository-properties to include this documentation instead, and then have a shorter entry here that references the docs.
Sorry, something went wrong.
| const initStatusReport: InitStatusReport = { | ||
| ...statusReportBase, | ||
| tools_input: getOptionalInput("tools") || "", | ||
| computed_tools_input: effectiveToolsInput || "", |
There was a problem hiding this comment.
It would probably be good to be consistent with the naming. (I.e. use "computed" or "effective" throughout.)
Sorry, something went wrong.
| if (repositoryPropertiesResult) { | ||
| if (repositoryPropertiesResult.isSuccess()) { | ||
| logger.debug( | ||
| `Loaded repository properties: ${Object.keys(repositoryPropertiesResult.value).join(", ")}`, | ||
| ); | ||
| toolsPropertyValue = | ||
| RepositoryPropertyName.TOOLS in repositoryPropertiesResult.value | ||
| ? (repositoryPropertiesResult.value[ | ||
| RepositoryPropertyName.TOOLS | ||
| ] as string) | ||
| : undefined; | ||
| } else { | ||
| logger.warning( | ||
| `Failed to load repository properties: ${repositoryPropertiesResult.value}`, | ||
| ); | ||
| toolsPropertyValue = undefined; | ||
| } | ||
| } | ||
| const effectiveToolsInput = toolsWorkflowInput || toolsPropertyValue; | ||
|
|
||
| // Log the source of the tools input for transparency | ||
| if (effectiveToolsInput) { | ||
| if (toolsWorkflowInput) { | ||
| logger.info( | ||
| `Setting tools: ${effectiveToolsInput} based on workflow input.`, | ||
| ); | ||
| } else { | ||
| logger.info( | ||
| `Setting tools: ${effectiveToolsInput} based on the '${RepositoryPropertyName.TOOLS}' repository property.`, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| return effectiveToolsInput; |
There was a problem hiding this comment.
This code seems excessively complicated to me. The semantics we decided on for the repository property is that it is a fallback in case that there is no explicit tools: input, yet we:
Why not simply:
Sorry, something went wrong.
| * @param logger - Logger for outputting resolution messages | ||
| * @returns The effective tools input value | ||
| */ | ||
| export async function resolveToolsInput( |
There was a problem hiding this comment.
Having this in its own file is better than in actions-util, but it would probably make sense to move this file into the src/config directory.
Sorry, something went wrong.
| toolsPropertyValue = | ||
| RepositoryPropertyName.TOOLS in repositoryPropertiesResult.value | ||
| ? (repositoryPropertiesResult.value[ | ||
| RepositoryPropertyName.TOOLS | ||
| ] as string) | ||
| : undefined; |
There was a problem hiding this comment.
This is unnecessarily complicated. Elsewhere, we have const repositoryProperties = repositoryPropertiesResult.orElse({}) to have a consistent object interface. Then
toolsPropertyValue = repositoryProperties[RepositoryPropertyName.TOOLS] is sufficient to get us a string | undefined value.
And repositoryProperties should be a parameter of this function (see my other comments).
Sorry, something went wrong.
|
|
||
| setupTests(test); | ||
|
|
||
| const repositoryNwo = { owner: "owner", repo: "repo" } as RepositoryNwo; |
There was a problem hiding this comment.
Use parseRepositoryNwo.
Sorry, something went wrong.
| sinon | ||
| .stub(actionsUtil, "getOptionalInput") | ||
| .withArgs("tools") | ||
| .returns(undefined); | ||
|
|
||
| sinon | ||
| .stub(properties, "loadRepositoryProperties") | ||
| .withArgs(repositoryNwo, logger) | ||
| .resolves(undefined); |
There was a problem hiding this comment.
If both of these values were inputs to resolveToolsInput, then the tests would not have to be serial.
Sorry, something went wrong.
| ); | ||
|
|
||
| test.serial( | ||
| "resolveToolsInput returns workflow input when only workflow input is provided", |
There was a problem hiding this comment.
This name isn't wrong as such, but could be slightly misleading. The value of the repository property shouldn't matter when the workflow input is provided, so this isn't a different case from the "resolveToolsInput prioritizes workflow input over repository property" test.
Sorry, something went wrong.
| .returns("2.15.0"); | ||
|
|
||
| const repositoryPropertiesResult = new Success({ | ||
| [RepositoryPropertyName.TOOLS]: "2.20.0", |
There was a problem hiding this comment.
This is irrelevant to the test outcome, so this being a specific value might be distracting in understanding the test behaviour.
Sorry, something went wrong.
| if (!allowRepositoryPropertyFallback) { | ||
| if (toolsPropertyValue) { | ||
| logger.info( | ||
| `No explicit tools input was provided. Ignoring '${RepositoryPropertyName.TOOLS}' repository property because it is only supported for dynamic workflows.`, | ||
| ); |
| effectiveToolsInput = resolveToolsInput( | ||
| getOptionalInput("tools"), | ||
| isDynamicWorkflow(), | ||
| repositoryProperties, | ||
| logger, |
| effectiveToolsInput = resolveToolsInput( | ||
| getOptionalInput("tools"), | ||
| isDynamicWorkflow(), | ||
| repositoryProperties, | ||
| logger, |
| if (allowToolcacheValueFF) { | ||
| logger.warning( | ||
| logger.info( | ||
| `Ignoring 'tools: ${toolsInput}' because the workflow was not triggered dynamically.`, | ||
| ); | ||
| } else { |
|
I went through the remaining blocking feedback and here’s the concrete before-merge checklist I’m working from: Proposed merge checklistSemantics / scope Final implementation: Two modes depending on github-codeql-tools-mode:
Keep resolveToolsInput as a pure precedence helper:
Coherent behavior across entrypoints:
toolcache handling:
Telemetry / logging
Tests / validation
Docs / changelog
My current read is that the main blocker is no longer “can this be implemented?” but “what exact semantics do we want, and is the implementation the simplest expression of those semantics?” If that sounds right, I’ll use this as the checklist for the next revision. |
Sorry, something went wrong.
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
Large organizations downloading a pinned CodeQL CLI version on every analysis run can hit rate limits. This adds a github-codeql-tools repository property that lets org admins set the tools source at org level, avoiding per-run downloads.
What changes
New repository property: github-codeql-tools
Implementation
Risk assessment
High risk: Not fully under a feature flag — the new code path activates when the repository property is set.
Which use cases does this change impact?
Workflow types:
Products:
Environments:
How did/will you validate this change?
If something goes wrong after this change is released, what are the mitigation and rollback strategies?
The repository property must be explicitly set by an org admin; no existing workflows are affected unless they set github-codeql-tools.
How will you know if something goes wrong after this change is released?
Are there any special considerations for merging or releasing this change?
Merge / deployment checklist
⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.