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

Pass ignore conditions via ENV to solve BOM issues #884

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/updater.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ docker run --rm -t \
-e DEPENDABOT_OPEN_PULL_REQUESTS_LIMIT=10 \
-e DEPENDABOT_EXTRA_CREDENTIALS=<your-extra-credentials> \
-e DEPENDABOT_ALLOW_CONDITIONS=<your-allowed-packages> \
-e DEPENDABOT_IGNORE_CONDITIONS=<your-ignored-packages> \
-e DEPENDABOT_BRANCH_NAME_SEPARATOR=<your-custom-separator> \
-e DEPENDABOT_MILESTONE=<your-work-item-id> \
-e DEPENDABOT_UPDATER_OPTIONS=<your-updater-options> \
Expand Down Expand Up @@ -47,6 +48,7 @@ docker run --rm -t \
-e DEPENDABOT_OPEN_PULL_REQUESTS_LIMIT=10 \
-e DEPENDABOT_EXTRA_CREDENTIALS='[{"type":"npm_registry","token":"<redacted>","registry":"npm.fontawesome.com"}]' \
-e DEPENDABOT_ALLOW_CONDITIONS='[{"dependency-name":"django*","dependency-type":"direct"}]' \
-e DEPENDABOT_IGNORE_CONDITIONS='[{"dependency-name":"@types/*"}]' \
-e DEPENDABOT_BRANCH_NAME_SEPARATOR='/' \
-e DEPENDABOT_MILESTONE=123 \
-e DEPENDABOT_UPDATER_OPTIONS='goprivate=true,kubernetes_updates=true' \
Expand All @@ -73,6 +75,7 @@ docker run --rm -t \
-e DEPENDABOT_OPEN_PULL_REQUESTS_LIMIT=10 \
-e DEPENDABOT_EXTRA_CREDENTIALS='[{"type":"npm_registry","token":"<redacted>","registry":"npm.fontawesome.com"}]' \
-e DEPENDABOT_ALLOW_CONDITIONS='[{"dependency-name":"django*","dependency-type":"direct"}]' \
-e DEPENDABOT_IGNORE_CONDITIONS='[{"dependency-name":"@types/*"}]' \
-e DEPENDABOT_BRANCH_NAME_SEPARATOR='/' \
-e DEPENDABOT_MILESTONE=123 \
-e DEPENDABOT_UPDATER_OPTIONS='goprivate=true,kubernetes_updates=true' \
Expand Down Expand Up @@ -104,7 +107,7 @@ To run the script, some environment variables are required.
|DEPENDABOT_OPEN_PULL_REQUESTS_LIMIT|**_Optional_**. The maximum number of open pull requests to have at any one time. Defaults to 5. Setting to 0 implies security only updates.|
|DEPENDABOT_EXTRA_CREDENTIALS|**_Optional_**. The extra credentials in JSON format. Extra credentials can be used to access private NuGet feeds, docker registries, maven repositories, etc. For example a private registry authentication (For example FontAwesome Pro: `[{"type":"npm_registry","token":"<redacted>","registry":"npm.fontawesome.com"}]`)|
|DEPENDABOT_ALLOW_CONDITIONS|**_Optional_**. The dependencies whose updates are allowed, in JSON format. This can be used to control which packages can be updated. For example: `[{\"dependency-name\":"django*",\"dependency-type\":\"direct\"}]`. See [official docs](https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/configuration-options-for-dependency-updates#allow) for more.|
|DEPENDABOT_IGNORE_CONDITIONS|**_Optional_**. The dependencies to be ignored, in JSON format. This can be used to control which packages can be updated. For example: `[{\"dependency-name\":\"express\",\"versions\":[\"4.x\",\"5.x\"]}]`. See [official docs](https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/configuration-options-for-dependency-updates#ignore) for more.<br/><br/>We do not pass this ENV by default from the extension/server to the container. It is intentional. The ruby script in the docker container does it automatically. Only use it if you want to override what is in the configuration file and you are comfortable with the untidiness. If you are having issues search for related issues such as https://github.com/tinglesoftware/dependabot-azure-devops/pull/582 before creating a new issue. You can also test against various reproductions such as https://dev.azure.com/tingle/dependabot/_git/repro-582|
|DEPENDABOT_IGNORE_CONDITIONS|**_Optional_**. The dependencies to be ignored, in JSON format. This can be used to control which packages can be updated. For example: `[{\"dependency-name\":\"express\",\"versions\":[\"4.x\",\"5.x\"]}]`. See [official docs](https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/configuration-options-for-dependency-updates#ignore) for more.|
|DEPENDABOT_LABELS|**_Optional_**. The custom labels to be used, in JSON format. This can be used to override the default values. For example: `[\"npm dependencies\",\"triage-board\"]`. See [official docs](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/customizing-dependency-updates#setting-custom-labels) for more.|
|DEPENDABOT_REVIEWERS|**_Optional_**. The identifiers of the users to review the pull requests, in JSON format. These shall be added as optional approvers. For example: `[\"23d9f23d-981e-4a0c-a975-8e5c665914ec\",\"62b67ef1-58e9-4be9-83d3-690a6fc67d6b\"]`.
|DEPENDABOT_ASSIGNEES|**_Optional_**. The identifiers of the users to be assigned to the pull requests, in JSON format. These shall be added as required approvers. For example: `[\"be9321e2-f404-4ffa-8d6b-44efddb04865\"]`. |
Expand Down
1 change: 1 addition & 0 deletions extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ schedules:
# variables declared below can be put in one or more Variable Groups for sharing across pipelines
variables:
DEPENDABOT_ALLOW_CONDITIONS: '[{\"dependency-name\":"django*",\"dependency-type\":\"direct\"}]' # packages allowed to be updated
DEPENDABOT_IGNORE_CONDITIONS: '[{\"dependency-name\":"@types/*"}]' # packages ignored to be updated

pool:
vmImage: 'ubuntu-latest' # requires macos or ubuntu (windows is not supported)
Expand Down
4 changes: 4 additions & 0 deletions extension/task/IDependabotConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export interface IDependabotUpdate {
* Customize which updates are allowed.
*/
allow?: string;
/**
* Customize which updates are ignored.
*/
ignore?: string;
/**
* Custom labels/tags.
*/
Expand Down
6 changes: 6 additions & 0 deletions extension/task/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ async function run() {
dockerRunner.arg(["-e", `DEPENDABOT_ALLOW_CONDITIONS=${allow}`]);
}

// Set the dependencies to ignore
let ignore = update.ignore;
if (ignore) {
dockerRunner.arg(["-e", `DEPENDABOT_IGNORE_CONDITIONS=${ignore}`]);
}

// Set the requirements that should not be unlocked
if (variables.excludeRequirementsToUnlock) {
dockerRunner.arg(["-e", `DEPENDABOT_EXCLUDE_REQUIREMENTS_TO_UNLOCK=${variables.excludeRequirementsToUnlock}`]);
Expand Down
1 change: 1 addition & 0 deletions extension/task/utils/parseConfigFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ function parseUpdates(config: any): IDependabotUpdate[] {

// Convert to JSON or as required by the script
allow: update["allow"] ? JSON.stringify(update["allow"]) : undefined,
ignore: update["ignore"] ? JSON.stringify(update["ignore"]) : undefined,
labels: update["labels"] ? JSON.stringify(update["labels"]) : undefined,
reviewers: update["reviewers"]
? JSON.stringify(update["reviewers"])
Expand Down
1 change: 1 addition & 0 deletions server/Tingle.Dependabot/Workflow/UpdateRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ internal async Task<IDictionary<string, string>> CreateEnvironmentVariables(Proj
.AddIfNotDefault("DEPENDABOT_REJECT_EXTERNAL_CODE", string.Equals(update.InsecureExternalCodeExecution, "deny").ToString().ToLowerInvariant())
.AddIfNotDefault("DEPENDABOT_VERSIONING_STRATEGY", update.VersioningStrategy)
.AddIfNotDefault("DEPENDABOT_ALLOW_CONDITIONS", ToJson(update.Allow))
.AddIfNotDefault("DEPENDABOT_IGNORE_CONDITIONS", ToJson(update.Ignore))
.AddIfNotDefault("DEPENDABOT_LABELS", ToJson(update.Labels))
.AddIfNotDefault("DEPENDABOT_BRANCH_NAME_SEPARATOR", update.PullRequestBranchName?.Separator)
.AddIfNotDefault("DEPENDABOT_MILESTONE", update.Milestone?.ToString());
Expand Down