Skip to content

[release-11.3.9] Actions: Backport actions #106985

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

Draft
wants to merge 11 commits into
base: release-11.3.10
Choose a base branch
from

Conversation

Proximyst
Copy link
Member

This backports the actions from main, along with necessary scripts and other moves.

This probably won't work for a while. Sorry.

Comment on lines +16 to +42
runs-on: ubuntu-latest
continue-on-error: true
if: github.event.pull_request.draft == false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Pin Go version to mod file
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- run: go version
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
- name: Install dependencies
run: yarn install --immutable
- name: Build grafana
run: make build
- name: Install Cypress dependencies
uses: cypress-io/github-action@108b8684ae52e735ff7891524cbffbcd4be5b19f
with:
runTests: false
- name: Run dashboardNewLayouts e2e
run: yarn e2e:dashboard-new-layouts

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 about 1 month ago

To fix the issue, add a permissions block to the root of the workflow file. This block will explicitly define the least privileges required for the workflow to function correctly. Based on the actions performed in the workflow, the contents: read permission is sufficient. This ensures that the workflow cannot perform write operations unless explicitly allowed.

The permissions block should be added at the top level of the workflow file, immediately after the name field. This will apply the permissions to all jobs in the workflow unless overridden by job-specific permissions blocks.

Suggested changeset 1
.github/workflows/e2e-dashboard-new-layouts.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/e2e-dashboard-new-layouts.yml b/.github/workflows/e2e-dashboard-new-layouts.yml
--- a/.github/workflows/e2e-dashboard-new-layouts.yml
+++ b/.github/workflows/e2e-dashboard-new-layouts.yml
@@ -1,2 +1,4 @@
 name: Run e2e for dashboardNewLayouts
+permissions:
+  contents: read
 
EOF
@@ -1,2 +1,4 @@
name: Run e2e for dashboardNewLayouts
permissions:
contents: read

Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +12 to +14
uses: grafana/grafana-github-actions/.github/workflows/crowdin-create-tasks.yml@main
with:
crowdin_project_id: 5

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: {}

Copilot Autofix

AI about 1 month ago

To fix the issue, add a permissions block at the root of the workflow file. This block will define the least privileges required for the workflow to function correctly. Based on the context, the workflow likely needs read access to repository contents and possibly write access to specific resources (e.g., pull requests or issues). As a starting point, we will set contents: read and adjust further if additional permissions are required.


Suggested changeset 1
.github/workflows/i18n-crowdin-create-tasks.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/i18n-crowdin-create-tasks.yml b/.github/workflows/i18n-crowdin-create-tasks.yml
--- a/.github/workflows/i18n-crowdin-create-tasks.yml
+++ b/.github/workflows/i18n-crowdin-create-tasks.yml
@@ -2,2 +2,5 @@
 
+permissions:
+  contents: read
+
 on:
EOF
@@ -2,2 +2,5 @@

permissions:
contents: read

on:
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +10 to +15
uses: grafana/grafana-github-actions/.github/workflows/crowdin-download.yml@main
with:
crowdin_project_id: 5
pr_labels: 'area/frontend, area/internationalization, no-changelog, no-backport'
github_board_id: 78 # Frontend Platform project
en_paths: public/locales/en-US/grafana.json, public/app/plugins/datasource/azuremonitor/locales/en-US/grafana-azure-monitor-datasource.json, public/app/plugins/datasource/mssql/locales/en-US/mssql.json, packages/grafana-prometheus/src/locales/en-US/grafana-prometheus.json, packages/grafana-sql/src/locales/en-US/grafana-sql.json

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: {}

Copilot Autofix

AI about 1 month ago

To fix the issue, we need to add a permissions block to the workflow. This block should specify the least privileges required for the workflow to function correctly. Based on the context, the workflow likely needs read access to repository contents and possibly write access to pull requests (if it creates or updates pull requests).

The permissions block can be added at the root level of the workflow to apply to all jobs or within the specific job (download-sources-from-crowdin) to limit permissions to that job only. Since the workflow uses a third-party action, we should consult its documentation to confirm the exact permissions required. For now, we will assume the minimal permissions needed are contents: read and pull-requests: write.


Suggested changeset 1
.github/workflows/i18n-crowdin-download.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/i18n-crowdin-download.yml b/.github/workflows/i18n-crowdin-download.yml
--- a/.github/workflows/i18n-crowdin-download.yml
+++ b/.github/workflows/i18n-crowdin-download.yml
@@ -2,2 +2,6 @@
 
+permissions:
+  contents: read
+  pull-requests: write
+
 on:
@@ -9,3 +13,3 @@
   download-sources-from-crowdin:
-    uses: grafana/grafana-github-actions/.github/workflows/crowdin-download.yml@main
+    uses: grafana/grafana-grafana-github-actions/.github/workflows/crowdin-download.yml@main
     with:
EOF
@@ -2,2 +2,6 @@

permissions:
contents: read
pull-requests: write

on:
@@ -9,3 +13,3 @@
download-sources-from-crowdin:
uses: grafana/grafana-github-actions/.github/workflows/crowdin-download.yml@main
uses: grafana/grafana-grafana-github-actions/.github/workflows/crowdin-download.yml@main
with:
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +17 to +19
uses: grafana/grafana-github-actions/.github/workflows/crowdin-upload.yml@main
with:
crowdin_project_id: 5

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: {}

Copilot Autofix

AI about 1 month ago

To fix the issue, we need to add a permissions block to the workflow. This block should specify the least privileges required for the workflow to function correctly. Since the workflow uploads sources to Crowdin, it likely only needs read access to the repository contents.

The permissions block should be added at the root level of the workflow to apply to all jobs, as there is only one job in this workflow. Alternatively, it can be added specifically to the upload-sources-to-crowdin job.

Suggested changeset 1
.github/workflows/i18n-crowdin-upload.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/i18n-crowdin-upload.yml b/.github/workflows/i18n-crowdin-upload.yml
--- a/.github/workflows/i18n-crowdin-upload.yml
+++ b/.github/workflows/i18n-crowdin-upload.yml
@@ -2,2 +2,5 @@
 
+permissions:
+  contents: read
+
 on:
EOF
@@ -2,2 +2,5 @@

permissions:
contents: read

on:
Copilot is powered by AI and may make mistakes. Always verify output.

This comment has been minimized.

1 similar comment

This comment has been minimized.

This comment has been minimized.


return d.Container().From("alpine/curl").
WithSecretVariable("GCOM_API_KEY", apiKeySecret).
WithExec([]string{"/bin/sh", "-c", fmt.Sprintf(`curl -H "Content-Type: application/json" -H "Authorization: Bearer $GCOM_API_KEY" -d '%s' %s`, string(jsonVersionPayload), versionApiUrl.String())}).

Check failure

Code scanning / CodeQL

Potentially unsafe quoting Critical

If this
JSON value
contains a single quote, it could break out of the enclosing quotes.

Copilot Autofix

AI about 1 month ago

To fix the issue, the JSON payload should be sanitized to escape single quotes before embedding it into the shell command. Alternatively, a safer approach is to avoid manual string construction and use an API that supports structured command execution. In this case, escaping single quotes using strings.ReplaceAll is a straightforward solution. This ensures that any single quotes in the JSON payload are properly escaped, preventing premature termination of the quoted string.

Steps to fix:

  1. Use strings.ReplaceAll to escape single quotes in the JSON payload.
  2. Ensure that backslashes are also escaped to avoid interference with the escaping mechanism.
  3. Replace the vulnerable fmt.Sprintf construction with the sanitized payload.

Suggested changeset 1
pkg/build/daggerbuild/gcom/publish.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/pkg/build/daggerbuild/gcom/publish.go b/pkg/build/daggerbuild/gcom/publish.go
--- a/pkg/build/daggerbuild/gcom/publish.go
+++ b/pkg/build/daggerbuild/gcom/publish.go
@@ -35,2 +35,5 @@
 	}
+	// Escape single quotes and backslashes in the JSON payload
+	sanitizedPayload := strings.ReplaceAll(string(jsonVersionPayload), `\`, `\\`)
+	sanitizedPayload = strings.ReplaceAll(sanitizedPayload, "'", "\\'")
 
@@ -40,3 +43,3 @@
 		WithSecretVariable("GCOM_API_KEY", apiKeySecret).
-		WithExec([]string{"/bin/sh", "-c", fmt.Sprintf(`curl -H "Content-Type: application/json" -H "Authorization: Bearer $GCOM_API_KEY" -d '%s' %s`, string(jsonVersionPayload), versionApiUrl.String())}).
+		WithExec([]string{"/bin/sh", "-c", fmt.Sprintf(`curl -H "Content-Type: application/json" -H "Authorization: Bearer $GCOM_API_KEY" -d '%s' %s`, sanitizedPayload, versionApiUrl.String())}).
 		Stdout(ctx)
@@ -52,2 +55,5 @@
 	}
+	// Escape single quotes and backslashes in the JSON payload
+	sanitizedPayload := strings.ReplaceAll(string(jsonPackagePayload), `\`, `\\`)
+	sanitizedPayload = strings.ReplaceAll(sanitizedPayload, "'", "\\'")
 
@@ -57,3 +63,3 @@
 		WithSecretVariable("GCOM_API_KEY", apiKeySecret).
-		WithExec([]string{"/bin/sh", "-c", fmt.Sprintf(`curl -H "Content-Type: application/json" -H "Authorization: Bearer $GCOM_API_KEY" -d '%s' %s`, string(jsonPackagePayload), packagesApiUrl.String())}).
+		WithExec([]string{"/bin/sh", "-c", fmt.Sprintf(`curl -H "Content-Type: application/json" -H "Authorization: Bearer $GCOM_API_KEY" -d '%s' %s`, sanitizedPayload, packagesApiUrl.String())}).
 		Stdout(ctx)
EOF
@@ -35,2 +35,5 @@
}
// Escape single quotes and backslashes in the JSON payload
sanitizedPayload := strings.ReplaceAll(string(jsonVersionPayload), `\`, `\\`)
sanitizedPayload = strings.ReplaceAll(sanitizedPayload, "'", "\\'")

@@ -40,3 +43,3 @@
WithSecretVariable("GCOM_API_KEY", apiKeySecret).
WithExec([]string{"/bin/sh", "-c", fmt.Sprintf(`curl -H "Content-Type: application/json" -H "Authorization: Bearer $GCOM_API_KEY" -d '%s' %s`, string(jsonVersionPayload), versionApiUrl.String())}).
WithExec([]string{"/bin/sh", "-c", fmt.Sprintf(`curl -H "Content-Type: application/json" -H "Authorization: Bearer $GCOM_API_KEY" -d '%s' %s`, sanitizedPayload, versionApiUrl.String())}).
Stdout(ctx)
@@ -52,2 +55,5 @@
}
// Escape single quotes and backslashes in the JSON payload
sanitizedPayload := strings.ReplaceAll(string(jsonPackagePayload), `\`, `\\`)
sanitizedPayload = strings.ReplaceAll(sanitizedPayload, "'", "\\'")

@@ -57,3 +63,3 @@
WithSecretVariable("GCOM_API_KEY", apiKeySecret).
WithExec([]string{"/bin/sh", "-c", fmt.Sprintf(`curl -H "Content-Type: application/json" -H "Authorization: Bearer $GCOM_API_KEY" -d '%s' %s`, string(jsonPackagePayload), packagesApiUrl.String())}).
WithExec([]string{"/bin/sh", "-c", fmt.Sprintf(`curl -H "Content-Type: application/json" -H "Authorization: Bearer $GCOM_API_KEY" -d '%s' %s`, sanitizedPayload, packagesApiUrl.String())}).
Stdout(ctx)
Copilot is powered by AI and may make mistakes. Always verify output.

return d.Container().From("alpine/curl").
WithSecretVariable("GCOM_API_KEY", apiKeySecret).
WithExec([]string{"/bin/sh", "-c", fmt.Sprintf(`curl -H "Content-Type: application/json" -H "Authorization: Bearer $GCOM_API_KEY" -d '%s' %s`, string(jsonPackagePayload), packagesApiUrl.String())}).

Check failure

Code scanning / CodeQL

Potentially unsafe quoting Critical

If this
JSON value
contains a single quote, it could break out of the enclosing quotes.

Copilot Autofix

AI about 1 month ago

To fix the issue, the JSON payload (jsonPackagePayload) should be sanitized to escape single quotes before embedding it into the shell command. Alternatively, a safer approach is to avoid manual string construction and use structured APIs or placeholders for the command arguments. In this case, the best solution is to escape single quotes using strings.ReplaceAll to ensure the payload does not break the quoted string in the shell command.

Changes to make:

  1. Sanitize jsonPackagePayload by escaping single quotes and backslashes before embedding it into the curl command.
  2. Apply the same fix to jsonVersionPayload in the PublishGCOMVersion function to ensure consistency and security.

Suggested changeset 1
pkg/build/daggerbuild/gcom/publish.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/pkg/build/daggerbuild/gcom/publish.go b/pkg/build/daggerbuild/gcom/publish.go
--- a/pkg/build/daggerbuild/gcom/publish.go
+++ b/pkg/build/daggerbuild/gcom/publish.go
@@ -35,2 +35,5 @@
 	}
+	// Escape single quotes and backslashes in the JSON payload
+	sanitizedPayload := strings.ReplaceAll(string(jsonVersionPayload), `\`, `\\`)
+	sanitizedPayload = strings.ReplaceAll(sanitizedPayload, "'", "\\'")
 
@@ -40,3 +43,3 @@
 		WithSecretVariable("GCOM_API_KEY", apiKeySecret).
-		WithExec([]string{"/bin/sh", "-c", fmt.Sprintf(`curl -H "Content-Type: application/json" -H "Authorization: Bearer $GCOM_API_KEY" -d '%s' %s`, string(jsonVersionPayload), versionApiUrl.String())}).
+		WithExec([]string{"/bin/sh", "-c", fmt.Sprintf(`curl -H "Content-Type: application/json" -H "Authorization: Bearer $GCOM_API_KEY" -d '%s' %s`, sanitizedPayload, versionApiUrl.String())}).
 		Stdout(ctx)
@@ -52,2 +55,5 @@
 	}
+	// Escape single quotes and backslashes in the JSON payload
+	sanitizedPayload := strings.ReplaceAll(string(jsonPackagePayload), `\`, `\\`)
+	sanitizedPayload = strings.ReplaceAll(sanitizedPayload, "'", "\\'")
 
@@ -57,3 +63,3 @@
 		WithSecretVariable("GCOM_API_KEY", apiKeySecret).
-		WithExec([]string{"/bin/sh", "-c", fmt.Sprintf(`curl -H "Content-Type: application/json" -H "Authorization: Bearer $GCOM_API_KEY" -d '%s' %s`, string(jsonPackagePayload), packagesApiUrl.String())}).
+		WithExec([]string{"/bin/sh", "-c", fmt.Sprintf(`curl -H "Content-Type: application/json" -H "Authorization: Bearer $GCOM_API_KEY" -d '%s' %s`, sanitizedPayload, packagesApiUrl.String())}).
 		Stdout(ctx)
EOF
@@ -35,2 +35,5 @@
}
// Escape single quotes and backslashes in the JSON payload
sanitizedPayload := strings.ReplaceAll(string(jsonVersionPayload), `\`, `\\`)
sanitizedPayload = strings.ReplaceAll(sanitizedPayload, "'", "\\'")

@@ -40,3 +43,3 @@
WithSecretVariable("GCOM_API_KEY", apiKeySecret).
WithExec([]string{"/bin/sh", "-c", fmt.Sprintf(`curl -H "Content-Type: application/json" -H "Authorization: Bearer $GCOM_API_KEY" -d '%s' %s`, string(jsonVersionPayload), versionApiUrl.String())}).
WithExec([]string{"/bin/sh", "-c", fmt.Sprintf(`curl -H "Content-Type: application/json" -H "Authorization: Bearer $GCOM_API_KEY" -d '%s' %s`, sanitizedPayload, versionApiUrl.String())}).
Stdout(ctx)
@@ -52,2 +55,5 @@
}
// Escape single quotes and backslashes in the JSON payload
sanitizedPayload := strings.ReplaceAll(string(jsonPackagePayload), `\`, `\\`)
sanitizedPayload = strings.ReplaceAll(sanitizedPayload, "'", "\\'")

@@ -57,3 +63,3 @@
WithSecretVariable("GCOM_API_KEY", apiKeySecret).
WithExec([]string{"/bin/sh", "-c", fmt.Sprintf(`curl -H "Content-Type: application/json" -H "Authorization: Bearer $GCOM_API_KEY" -d '%s' %s`, string(jsonPackagePayload), packagesApiUrl.String())}).
WithExec([]string{"/bin/sh", "-c", fmt.Sprintf(`curl -H "Content-Type: application/json" -H "Authorization: Bearer $GCOM_API_KEY" -d '%s' %s`, sanitizedPayload, packagesApiUrl.String())}).
Stdout(ctx)
Copilot is powered by AI and may make mistakes. Always verify output.
@grafana-delivery-bot grafana-delivery-bot bot changed the base branch from release-11.3.9 to release-11.3.10 July 23, 2025 20:07
Copy link
Contributor

Hello @Proximyst, we've noticed that the original base branch release-11.3.9 for this PR is no longer a release candidate. We've automatically updated your PR's base branch to the current release target: release-11.3.10. Please review and resolve any potential merge conflicts. If this PR is not merged it will NOT be included in the next release. Thanks!

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.

1 participant