Skip to content

feat: add Windows 2019 and Windows 2022 infrastructure bundle images(NR-528123)#641

Draft
nravada wants to merge 4 commits into
masterfrom
NR-528123
Draft

feat: add Windows 2019 and Windows 2022 infrastructure bundle images(NR-528123)#641
nravada wants to merge 4 commits into
masterfrom
NR-528123

Conversation

@nravada

@nravada nravada commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread .github/workflows/build.yml Fixed
Comment on lines +96 to +113
name: Build Windows 2022 image
runs-on: windows-2022
env:
DOCKER_IMAGE: newrelic/infrastructure-bundle
DOCKER_IMAGE_TAG: ci
WINDOWS_VERSION: ltsc2022
steps:
- uses: actions/checkout@v4
- name: Switch to Windows containers
run: |
& "$Env:ProgramFiles\Docker\Docker\DockerCli.exe" -SwitchWindowsEngine
shell: pwsh
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build Windows 2022 image
shell: bash
run: ./docker-build-windows.sh

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 3 months ago

To fix the problem, explicitly define GITHUB_TOKEN permissions in the workflow, restricting them to the minimum needed. Since none of the jobs in .github/workflows/build.yml appear to require write access to the repository (they only check out code, set up QEMU/Buildx/Go, build images, and run validation), a safe and minimal configuration is to set permissions: contents: read at the top (workflow) level. This applies to all jobs that do not override permissions, including build-windows-2022.

Concretely, in .github/workflows/build.yml, add a permissions block between the name: Container build line and the on: block. For example:

name: Container build
permissions:
  contents: read
on:
  push:
  ...

No additional imports or methods are needed because this is purely a YAML configuration change. We do not need per-job permissions blocks unless a specific job needs different permissions; based on the provided snippet, that is not required.

Suggested changeset 1
.github/workflows/build.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -1,5 +1,7 @@
 ---
 name: Container build
+permissions:
+  contents: read
 on:
   push:
     branches:
EOF
@@ -1,5 +1,7 @@
---
name: Container build
permissions:
contents: read
on:
push:
branches:
Copilot is powered by AI and may make mistakes. Always verify output.
Comment thread .github/workflows/nightly.yml Fixed
Comment on lines +85 to +106
name: Nightly Windows 2022 build
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Switch to Windows containers
run: |
& "$Env:ProgramFiles\Docker\Docker\DockerCli.exe" -SwitchWindowsEngine
shell: pwsh
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: docker/login-action@v3
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
- name: Build and push nightly Windows 2022 image
shell: bash
env:
DOCKER_IMAGE: newrelic/infrastructure-bundle
DOCKER_IMAGE_TAG: nightly
WINDOWS_VERSION: ltsc2022
run: ./docker-build-windows.sh --push

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 3 months ago

In general, the fix is to add an explicit permissions block that restricts the GITHUB_TOKEN to the minimal access the job needs, typically contents: read when the job only needs to check out code. This block can be added at the workflow root (affecting all jobs without their own permissions) or specifically on the flagged job.

To fix this workflow without changing its behavior, add permissions: contents: read at the top level, just after name: Nightly build (line 1). All jobs in this workflow only appear to need read access to repository contents (checkout operations); they push Docker images using registry credentials from secrets, not GITHUB_TOKEN. A root-level permissions block will therefore satisfy CodeQL’s requirement and apply the least privilege consistently across nightly, nightly-fips, nightly-windows-2019, and nightly-windows-2022, without altering any existing steps.

Concretely:

  • Edit .github/workflows/nightly.yml.
  • Insert:
permissions:
  contents: read

between the existing name: and on: keys. No additional imports, methods, or other definitions are required.

Suggested changeset 1
.github/workflows/nightly.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -1,4 +1,6 @@
 name: Nightly build
+permissions:
+  contents: read
 on:
   schedule:
     - cron: "0 3 * * *"
EOF
@@ -1,4 +1,6 @@
name: Nightly build
permissions:
contents: read
on:
schedule:
- cron: "0 3 * * *"
Copilot is powered by AI and may make mistakes. Always verify output.
Comment thread .github/workflows/on-demand.yml Fixed
Comment on lines +122 to +144
name: Build and push Windows 2022 image
runs-on: windows-2022
env:
DOCKER_IMAGE: newrelic/infrastructure-bundle
DOCKER_IMAGE_TAG: dev
AGENT_VERSION: ${{ github.event.inputs.agent_version }}
WINDOWS_VERSION: ltsc2022
steps:
- uses: actions/checkout@v4
- name: Switch to Windows containers
run: |
& "$Env:ProgramFiles\Docker\Docker\DockerCli.exe" -SwitchWindowsEngine
shell: pwsh
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: docker/login-action@v3
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
- name: Build and push Windows 2022 image
shell: bash
run: ./docker-build-windows.sh --push

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 3 months ago

In general, the fix is to explicitly restrict GITHUB_TOKEN permissions in the workflow to the minimum required, instead of relying on repository/organization defaults. For this workflow, the jobs only need to read repository contents (for actions/checkout); no job appears to require write access to the GitHub API.

The best, non-invasive fix is to add a root-level permissions block just under the name: (and before on:) that applies to all jobs. Set it to contents: read, which is sufficient for actions/checkout while preventing unnecessary write permissions. No other functionality is changed, and no additional imports or methods are needed because this is a pure YAML configuration update in .github/workflows/on-demand.yml.

Concretely, in .github/workflows/on-demand.yml, insert:

permissions:
  contents: read

after line 1 (name: On demand build). No per-job overrides are required.

Suggested changeset 1
.github/workflows/on-demand.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/on-demand.yml b/.github/workflows/on-demand.yml
--- a/.github/workflows/on-demand.yml
+++ b/.github/workflows/on-demand.yml
@@ -1,4 +1,6 @@
 name: On demand build
+permissions:
+  contents: read
 on:
   workflow_dispatch:
     inputs:
EOF
@@ -1,4 +1,6 @@
name: On demand build
permissions:
contents: read
on:
workflow_dispatch:
inputs:
Copilot is powered by AI and may make mistakes. Always verify output.
Comment thread .github/workflows/release.yml Fixed
Comment on lines +94 to +132
container-release-windows-2022:
name: Release Windows 2022 image
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Switch to Windows containers
run: |
& "$Env:ProgramFiles\Docker\Docker\DockerCli.exe" -SwitchWindowsEngine
shell: pwsh
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: docker/login-action@v3
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
- name: Set release tag
id: release_tag
shell: bash
run: |
TAG="${{ github.event.release.tag_name }}"
TAG="${TAG#v}"
if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then
TAG="${TAG}-rc"
fi
echo "tag=${TAG}" >> $GITHUB_OUTPUT
- name: Build and push Windows 2022 image
shell: bash
env:
DOCKER_IMAGE: newrelic/infrastructure-bundle
DOCKER_IMAGE_TAG: ${{ steps.release_tag.outputs.tag }}
WINDOWS_VERSION: ltsc2022
run: ./docker-build-windows.sh --push
- name: Push latest tag for Windows 2022
if: ${{ github.event.release.prerelease == false }}
shell: bash
run: |
docker tag "newrelic/infrastructure-bundle:${{ steps.release_tag.outputs.tag }}-servercore-ltsc2022" \
"newrelic/infrastructure-bundle:latest-servercore-ltsc2022"

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 3 months ago

To fix the problem, explicitly define a permissions block to restrict the default GITHUB_TOKEN permissions instead of relying on inherited repository defaults. Since the jobs only need to read the repository contents (for actions/checkout) and do not appear to require write access to issues, pull requests, or contents, we can safely set contents: read at the workflow level. This will apply to all jobs (container-release, container-release-fips, container-release-windows-2019, and container-release-windows-2022) and avoids duplicating the same permissions for each job.

The single best change, without altering existing behavior, is to add a top-level permissions block right after name: Container release (before on:). This keeps the jobs intact and simply constrains the GITHUB_TOKEN. No imports or external packages are needed, as this is purely a YAML configuration change inside .github/workflows/release.yml.

Suggested changeset 1
.github/workflows/release.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1,4 +1,6 @@
 name: Container release
+permissions:
+  contents: read
 on:
   release:
     types: [ prereleased, released ]
EOF
@@ -1,4 +1,6 @@
name: Container release
permissions:
contents: read
on:
release:
types: [ prereleased, released ]
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +76 to +102
name: Build Windows 2019 image
runs-on: windows-2022
env:
DOCKER_IMAGE: newrelic/infrastructure-bundle
DOCKER_IMAGE_TAG: ci
WINDOWS_VERSION: ltsc2019
steps:
- uses: actions/checkout@v4
- name: Switch to Windows containers
run: |
Stop-Service docker -Force
$configPath = "$env:ProgramData\docker\config\daemon.json"
if (-not (Test-Path (Split-Path $configPath))) {
New-Item -ItemType Directory -Force -Path (Split-Path $configPath) | Out-Null
}
Set-Content -Path $configPath -Value '{"experimental":true}'
Start-Service docker
Start-Sleep 5
shell: pwsh
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build Windows 2019 image
shell: bash
run: ./docker-build-windows.sh

build-windows-2022:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 3 months ago

In general, the fix is to add an explicit permissions: block that grants only the minimal required scopes for GITHUB_TOKEN. Since these jobs just build and scan images, check out code, and validate markdown, they only need read access to repository contents; no write scopes are required.

The best minimal fix without changing existing functionality is to add a workflow‑level permissions: block after the name: (or after on:) setting contents: read. This will apply to all jobs (build, build-fips, build-windows-2019, build-windows-2022) since none of them define their own permissions:. No additional imports or definitions are needed; this is a pure YAML configuration change in .github/workflows/build.yml.

Concretely:

  • Edit .github/workflows/build.yml.
  • Insert:
permissions:
  contents: read

right after the name: Container build line (line 2 in the snippet). This constrains GITHUB_TOKEN for all jobs, resolving the CodeQL finding for the build-windows-2019 job and the workflow as a whole.

Suggested changeset 1
.github/workflows/build.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -1,5 +1,7 @@
 ---
 name: Container build
+permissions:
+  contents: read
 on:
   push:
     branches:
EOF
@@ -1,5 +1,7 @@
---
name: Container build
permissions:
contents: read
on:
push:
branches:
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +61 to +91
name: Nightly Windows 2019 build
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Switch to Windows containers
run: |
Stop-Service docker -Force
$configPath = "$env:ProgramData\docker\config\daemon.json"
if (-not (Test-Path (Split-Path $configPath))) {
New-Item -ItemType Directory -Force -Path (Split-Path $configPath) | Out-Null
}
Set-Content -Path $configPath -Value '{"experimental":true}'
Start-Service docker
Start-Sleep 5
shell: pwsh
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: docker/login-action@v3
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
- name: Build and push nightly Windows 2019 image
shell: bash
env:
DOCKER_IMAGE: newrelic/infrastructure-bundle
DOCKER_IMAGE_TAG: nightly
WINDOWS_VERSION: ltsc2019
run: ./docker-build-windows.sh --push

nightly-windows-2022:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 3 months ago

In general, fix this by explicitly setting a permissions block either at the workflow root (applies to all jobs without their own permissions) or on each job, granting only the scopes actually required (usually contents: read for build jobs that just check out code). For the shown workflow, the nightly-windows-2019 and nightly-windows-2022 jobs only need to read repository contents and use external credentials (via secrets) to log into Docker Hub; they don’t appear to call GitHub APIs that require write access. The simplest, least-disruptive fix is to define a single workflow-level permissions block with contents: read, which will apply to all jobs here (including the reusable-workflow jobs, unless they override it). This both satisfies CodeQL and enforces least privilege going forward.

Concretely, edit .github/workflows/nightly.yml to add:

permissions:
  contents: read

near the top of the workflow, after the name: and before on:. No imports or additional definitions are needed, since this is just YAML configuration. This change should not affect existing functionality, as the jobs already behave correctly with at least contents: read (required by actions/checkout).

Suggested changeset 1
.github/workflows/nightly.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -1,4 +1,6 @@
 name: Nightly build
+permissions:
+  contents: read
 on:
   schedule:
     - cron: "0 3 * * *"
EOF
@@ -1,4 +1,6 @@
name: Nightly build
permissions:
contents: read
on:
schedule:
- cron: "0 3 * * *"
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +97 to +128
name: Build and push Windows 2019 image
runs-on: windows-2022
env:
DOCKER_IMAGE: newrelic/infrastructure-bundle
DOCKER_IMAGE_TAG: dev
AGENT_VERSION: ${{ github.event.inputs.agent_version }}
WINDOWS_VERSION: ltsc2019
steps:
- uses: actions/checkout@v4
- name: Switch to Windows containers
run: |
Stop-Service docker -Force
$configPath = "$env:ProgramData\docker\config\daemon.json"
if (-not (Test-Path (Split-Path $configPath))) {
New-Item -ItemType Directory -Force -Path (Split-Path $configPath) | Out-Null
}
Set-Content -Path $configPath -Value '{"experimental":true}'
Start-Service docker
Start-Sleep 5
shell: pwsh
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: docker/login-action@v3
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
- name: Build and push Windows 2019 image
shell: bash
run: ./docker-build-windows.sh --push

build-windows-2022:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 3 months ago

In general, you fix this by explicitly setting permissions for the GITHUB_TOKEN either at the workflow root (applies to all jobs without their own permissions) or on each job, and restricting it to the minimal scope needed, typically contents: read for build/publish workflows that don’t modify repo state.

For this workflow, the best minimal change without altering existing functionality is to add a root-level permissions: block right under the workflow name: (before on:). None of the jobs require write access to the repository with GITHUB_TOKEN; they use actions/checkout, Docker-related actions, Trivy, and Docker Hub credentials via secrets, all of which work with contents: read. Therefore, we set:

permissions:
  contents: read

This will cover all jobs (build, build-fips, build-windows-2019, build-windows-2022) without needing per-job edits. Concretely, in .github/workflows/on-demand.yml, insert the permissions: block between line 1 (name: On demand build) and line 2 (on:). No imports or other definitions are required.

Suggested changeset 1
.github/workflows/on-demand.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/on-demand.yml b/.github/workflows/on-demand.yml
--- a/.github/workflows/on-demand.yml
+++ b/.github/workflows/on-demand.yml
@@ -1,4 +1,6 @@
 name: On demand build
+permissions:
+  contents: read
 on:
   workflow_dispatch:
     inputs:
EOF
@@ -1,4 +1,6 @@
name: On demand build
permissions:
contents: read
on:
workflow_dispatch:
inputs:
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +54 to +101
container-release-windows-2019:
name: Release Windows 2019 image
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Switch to Windows containers
run: |
Stop-Service docker -Force
$configPath = "$env:ProgramData\docker\config\daemon.json"
if (-not (Test-Path (Split-Path $configPath))) {
New-Item -ItemType Directory -Force -Path (Split-Path $configPath) | Out-Null
}
Set-Content -Path $configPath -Value '{"experimental":true}'
Start-Service docker
Start-Sleep 5
shell: pwsh
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: docker/login-action@v3
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
- name: Set release tag
id: release_tag
shell: bash
run: |
TAG="${{ github.event.release.tag_name }}"
TAG="${TAG#v}"
if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then
TAG="${TAG}-rc"
fi
echo "tag=${TAG}" >> $GITHUB_OUTPUT
- name: Build and push Windows 2019 image
shell: bash
env:
DOCKER_IMAGE: newrelic/infrastructure-bundle
DOCKER_IMAGE_TAG: ${{ steps.release_tag.outputs.tag }}
WINDOWS_VERSION: ltsc2019
run: ./docker-build-windows.sh --push
- name: Push latest tag for Windows 2019
if: ${{ github.event.release.prerelease == false }}
shell: bash
run: |
docker tag "newrelic/infrastructure-bundle:${{ steps.release_tag.outputs.tag }}-servercore-ltsc2019" \
"newrelic/infrastructure-bundle:latest-servercore-ltsc2019"
docker push "newrelic/infrastructure-bundle:latest-servercore-ltsc2019"

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 3 months ago

In general, fix this by explicitly defining a permissions block that grants only the scopes the workflow actually needs, either at the workflow root (applies to all jobs) or per job. Here, none of the jobs appear to need to write back to the GitHub repository; they only read the release event and source code. Therefore contents: read is a safe minimal permission set.

The best fix with minimal functional change is to add a single top-level permissions block after the on: section, e.g. on a new line after line 4. This will apply to all jobs (container-release, container-release-fips, container-release-windows-2019, and container-release-windows-2022) that don’t override permissions, satisfying CodeQL’s requirement and constraining GITHUB_TOKEN to read-only repository contents. No additional methods, imports, or definitions are needed; this is a pure YAML configuration change.

Suggested changeset 1
.github/workflows/release.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -3,6 +3,9 @@
   release:
     types: [ prereleased, released ]
 
+permissions:
+  contents: read
+
 jobs:
   container-release:
     uses: newrelic/coreint-automation/.github/workflows/reusable_image_release.yaml@v3
EOF
@@ -3,6 +3,9 @@
release:
types: [ prereleased, released ]

permissions:
contents: read

jobs:
container-release:
uses: newrelic/coreint-automation/.github/workflows/reusable_image_release.yaml@v3
Copilot is powered by AI and may make mistakes. Always verify output.
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.

2 participants