Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
09bc569
feat: run plugin-validator as part of CI (opt-in)
xnyo Nov 3, 2025
2f4c431
removed unnecessary cd
xnyo Nov 3, 2025
cd1239d
pass configuration to plugin validator
xnyo Nov 4, 2025
b924345
Merge branch 'main' into giuseppe/validator
xnyo Nov 4, 2025
dc29f0a
shellcheck
xnyo Nov 4, 2025
cce6c6a
test gha annotations output
xnyo Nov 5, 2025
da228d3
exit plugin-validator step with plugin-validator container exit code
xnyo Nov 5, 2025
c2cde67
remove debug output
xnyo Nov 5, 2025
11f56a6
pass source code uri to plugin-validator
xnyo Nov 5, 2025
bc95bc7
reportAll
xnyo Nov 5, 2025
00622c9
disable clamav to speed up analysis
xnyo Nov 5, 2025
e0e0c07
enable debug mode
xnyo Nov 5, 2025
5f69e9c
actionlint?
xnyo Nov 5, 2025
7e98ab7
Merge branch 'main' into giuseppe/validator
xnyo Nov 5, 2025
e53c3df
add -ghaOutput flag to validator
xnyo Nov 5, 2025
b68ede2
add plugin-validator-config-file and plugin-validator-config-path inputs
xnyo Nov 6, 2025
dbd3a0b
actionlint
xnyo Nov 6, 2025
c11331c
add smoke test for plugin-validator
xnyo Nov 6, 2025
32660f0
fix concurrency with simple-ci tests
xnyo Nov 6, 2025
becb972
pass only plugin directory to plugin validator when not ci is not run…
xnyo Nov 6, 2025
236971b
test matrix for config file
xnyo Nov 6, 2025
a9d73c8
remove read only from config bind mount
xnyo Nov 6, 2025
79b1c31
fix artifacts conflict
xnyo Nov 6, 2025
500e85d
simplify smoke test
xnyo Nov 6, 2025
5f114ed
add validator inputs to cd, reorganize ci inputs in cd workflow
xnyo Nov 6, 2025
13f8672
reduce diff
xnyo Nov 6, 2025
0bd8be3
do not mount node_modules
xnyo Nov 6, 2025
1740f25
comments
xnyo Nov 6, 2025
c920981
Merge branch 'main' into giuseppe/validator
xnyo Nov 10, 2025
6f309a0
rename plugin-validator-config-file input to plugin-validator-config
xnyo Nov 10, 2025
31e91b8
remove warning when config file is missing, changed default config
xnyo Nov 10, 2025
51859a2
adjust config inputs priority
xnyo Nov 10, 2025
d9dd736
check if config path is a directory
xnyo Nov 10, 2025
9e0d956
remove redundant check
xnyo Nov 11, 2025
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
39 changes: 37 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,31 @@ on:
type: string
required: false

# Artifacts attestation for build provenance
# Feature toggle: plugin-validator
run-plugin-validator:
description: Whether to run plugin-validator.
type: boolean
required: false
default: false
plugin-validator-config:
description: |
Content of the plugin validator configuration file (yaml) to use.
It has higher priority than `plugin-validator-config-path` input.
If not provided, the action will look for the file specified in `plugin-validator-config-path` input instead.
If neither is provided, a default configuration will be used.
type: string
required: false
default: ""
plugin-validator-config-path:
description: |
Path to the plugin validator configuration file (yaml) to use.
It will be used only if `plugin-validator-config` input is not provided.
If not provided, a default configuration will be used.
type: string
required: false
default: ""

# Feature toggle: Artifacts attestation for build provenance
attestation:
description: Create a verifiable attestation for the plugin using Github OIDC.
type: boolean
Expand Down Expand Up @@ -389,12 +413,20 @@ jobs:
with:
branch: ${{ inputs.branch }}
plugin-directory: ${{ inputs.plugin-directory }}
plugin-version-suffix: ${{ needs.setup.outputs.plugin-version-suffix }}

package-manager: ${{ inputs.package-manager }}
npm-registry-auth: ${{ inputs.npm-registry-auth }}

go-version: ${{ inputs.go-version }}
go-setup-caching: ${{ inputs.go-setup-caching }}
node-version: ${{ inputs.node-version }}
golangci-lint-version: ${{ inputs.golangci-lint-version }}

run-plugin-validator: ${{ inputs.run-plugin-validator }}
plugin-validator-config: ${{ inputs.plugin-validator-config }}
plugin-validator-config-path: ${{ inputs.plugin-validator-config-path }}

run-playwright: ${{ inputs.run-playwright }}
run-playwright-docker: ${{ inputs.run-playwright-docker }}
run-playwright-with-grafana-dependency: ${{ inputs.run-playwright-with-grafana-dependency }}
Expand All @@ -406,14 +438,17 @@ jobs:
playwright-config: ${{ inputs.playwright-config }}
playwright-grafana-url: ${{ inputs.playwright-grafana-url }}
playwright-secrets: ${{ inputs.playwright-secrets }}

run-trufflehog: ${{ inputs.run-trufflehog }}
trufflehog-version: ${{ inputs.trufflehog-version }}
trufflehog-include-detectors: ${{ inputs.trufflehog-include-detectors }}
trufflehog-exclude-detectors: ${{ inputs.trufflehog-exclude-detectors }}
plugin-version-suffix: ${{ needs.setup.outputs.plugin-version-suffix }}

frontend-secrets: ${{ inputs.frontend-secrets }}
backend-secrets: ${{ inputs.backend-secrets }}

environment: ${{ inputs.environment }}

allow-unsigned: ${{ inputs.allow-unsigned }}
signature-type: ${{ inputs.signature-type }}

Expand Down
76 changes: 76 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,30 @@ on:
type: string
required: false

# Feature toggle: plugin-validator
run-plugin-validator:
description: Whether to run plugin-validator.
type: boolean
required: false
default: false
plugin-validator-config:
description: |
Content of the plugin validator configuration file (yaml) to use.
It has higher priority than `plugin-validator-config-path` input.
If not provided, the action will look for the file specified in `plugin-validator-config-path` input instead.
If neither is provided, a default configuration will be used.
type: string
required: false
default: ""
plugin-validator-config-path:
description: |
Path to the plugin validator configuration file (yaml) to use.
It will be used only if `plugin-validator-config` input is not provided.
If not provided, a default configuration will be used.
type: string
required: false
default: ""

# Options for building PRs. Those values should come from the PR event and should not be set manually.
plugin-version-suffix:
description: |
Expand Down Expand Up @@ -438,6 +462,58 @@ jobs:
include-detectors: ${{ inputs.trufflehog-include-detectors }}
exclude-detectors: ${{ inputs.trufflehog-exclude-detectors }}

- name: plugin-validator
if: ${{ inputs.run-plugin-validator == true }}
run: |
if [ -n "${PLUGIN_VALIDATOR_CONFIG}" ]; then
# User-provided configuration content
echo "Using provided plugin-validator configuration content."
PLUGIN_VALIDATOR_CONFIG_PATH=".plugin-validator.yaml"
echo "${PLUGIN_VALIDATOR_CONFIG}" > ${PLUGIN_VALIDATOR_CONFIG_PATH}
elif [ -n "${PLUGIN_VALIDATOR_CONFIG_PATH}" ]; then
# User-provided configuration file path
echo "Using plugin-validator configuration file at path: ${PLUGIN_VALIDATOR_CONFIG_PATH}"
if [ ! -f "${PLUGIN_VALIDATOR_CONFIG_PATH}" ]; then
echo "::error title=plugin-validator: missing config file::${PLUGIN_VALIDATOR_CONFIG_PATH} configuration file is missing."
exit 1
fi
else
# Default hardcoded configuration
PLUGIN_VALIDATOR_CONFIG_PATH=".plugin-validator.yaml"
echo "${PLUGIN_VALIDATOR_CONFIG_PATH} configuration file is missing. Providing a default one as fallback."
cat <<EOF > "${PLUGIN_VALIDATOR_CONFIG_PATH}"
global:
enabled: true
EOF
fi

echo "Using configuration:"
cat "${PLUGIN_VALIDATOR_CONFIG_PATH}"

# Create an empty dir for mounting it instead of node_modules, otherwise some validator analyzers
# will recurse into the plugin's directory (including node_modules).
mkdir -p /tmp/empty

# Do not run clamav because it takes too long
docker run --name=plugin-validator --pull=always \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we are not going to run clamav we might benefit from using npx directly which can be faster than pulling and running the whole docker image? just see if that might speed up things

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about semgrep, osv-scanner and gosec? The readme specifies they should be installed:

https://github.com/grafana/plugin-validator?tab=readme-ov-file#security-tools

I am not sure about osv-scanner because it looks like it's being used as a library and it should work even if it's not installed on the system.

semgrep requires the executable: https://github.com/grafana/plugin-validator/blob/e985ef06cef56f260ed0af03fa08b94f495e952a/pkg/analysis/passes/coderules/coderules.go#L95

gosec too: https://github.com/grafana/plugin-validator/blob/e985ef06cef56f260ed0af03fa08b94f495e952a/pkg/analysis/passes/gosec/gosec.go#L43

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are correct. semgrep and gosect require system install. osv-scanner uses the go library so works via npx

-v "$PWD/${PLUGIN_VALIDATOR_CONFIG_PATH}:/workspace/.plugin-validator.yaml:ro" \
-v "$PWD/dist-artifacts:/workspace/dist-artifacts:ro" \
-v "$PWD/${PLUGIN_DIRECTORY}:/workspace" \
-v "/tmp/empty:/workspace/node_modules" \
-e SKIP_CLAMAV=1 \
grafana/plugin-validator-cli \
-ghaOutput \
-config=/workspace/.plugin-validator.yaml \
-sourceCodeUri=file:///workspace \
"/workspace/dist-artifacts/${UNIVERSAL_ZIP}"
exit "$(docker inspect plugin-validator --format='{{.State.ExitCode}}')"
env:
UNIVERSAL_ZIP: ${{ steps.universal-zip.outputs.zip }}
PLUGIN_VALIDATOR_CONFIG: ${{ inputs.plugin-validator-config }}
PLUGIN_VALIDATOR_CONFIG_PATH: ${{ inputs.plugin-validator-config-path }}
PLUGIN_DIRECTORY: ${{ inputs.plugin-directory }}
shell: bash

- name: Define outputs
id: outputs
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@ jobs:

# TODO: enable in a follow-up PR
run-playwright: false

run-plugin-validator: true
Loading