-
Notifications
You must be signed in to change notification settings - Fork 2
feat(ci): add PyPI release workflow for splunk-ao-a2a #56
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| name: Release splunk-ao-a2a to PyPI | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: 'Version to release (e.g., 0.1.0, 1.2.3, 1.2.3rc1, 1.2.3.post1). Must be an explicit version — bump keywords like "patch" or "minor" are not accepted.' | ||
| required: true | ||
| type: string | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build package | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| defaults: | ||
| run: | ||
| working-directory: splunk-ao-a2a | ||
| outputs: | ||
| version: ${{ steps.get-version.outputs.version }} | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: Set version | ||
| env: | ||
| INPUT_VERSION: ${{ inputs.version }} | ||
| run: | | ||
| if ! printf '%s' "$INPUT_VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+((a|b|rc)[0-9]+)?(\.post[0-9]+)?(\.dev[0-9]+)?$'; then | ||
| echo "::error::Invalid version '${INPUT_VERSION}'. Expected an explicit version like 0.1.0, 1.2.3rc1, or 1.2.3.post1. Bump keywords like 'patch' or 'major' are not accepted." | ||
| exit 1 | ||
| fi | ||
| sed -i "s/^version = \".*\"/version = \"${INPUT_VERSION}\"/" pyproject.toml | ||
| sed -i "s/__version__ = \".*\"/__version__ = \"${INPUT_VERSION}\"/" src/splunk_ao_a2a/_version.py | ||
|
|
||
| - name: Get current version | ||
| id: get-version | ||
| run: | | ||
| VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/') | ||
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Build package | ||
| run: | | ||
| pip install build | ||
| python -m build | ||
|
|
||
| - name: Upload distributables | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | ||
| with: | ||
| name: splunk-ao-a2a-${{ steps.get-version.outputs.version }} | ||
| path: splunk-ao-a2a/dist/ | ||
|
|
||
| publish: | ||
| name: Publish to PyPI | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| id-token: write # Required for OIDC trusted publishing | ||
| environment: | ||
| name: pypi | ||
| url: https://pypi.org/project/splunk-ao-a2a/ | ||
|
|
||
| steps: | ||
| - name: Download distributables | ||
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | ||
| with: | ||
| name: splunk-ao-a2a-${{ needs.build.outputs.version }} | ||
| path: dist/ | ||
|
|
||
| - name: Publish to PyPI | ||
| uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1 | ||
| with: | ||
| verbose: true | ||
| print-hash: true | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 major (security): The version validation can be bypassed by a multi-line input, which then flows unsanitized into the
sedreplacement string.grep -Eq '^...$'matches on a per-line basis, so an input such as0.1.0\n<arbitrary>passes the check (line 1 matches) even though the whole value is not a valid version. The raw$INPUT_VERSIONis then interpolated intosed -i "s/^version = \".*\"/version = \"${INPUT_VERSION}\"/"; an embedded newline terminates thescommand and the remainder is parsed as additionalsedcommands (e.g.e/w), giving command/file-write execution in CI.workflow_dispatchstring inputs are single-line in the UI but can contain newlines when dispatched via the REST API /gh workflow run. Although dispatching requires write access, code execution inside a release pipeline is worth closing off. Prefer bash's[[ =~ ]], whose^/$anchor the entire string and where.does not cross newlines, so multi-line input is rejected. The same hardening should be mirrored in any sibling release workflow.🤖 Generated by Astra
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch — switched from
grep -Eqto bash[[ =~ ]]across all three PyPI release workflows. The[[ =~ ]]operator anchors^/$to the entire string rather than matching per-line, so a multi-line input like0.1.0\n<payload>is now rejected outright. Fixed in PR #59.