generated from devcontainers/feature-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/aikido version mgmt #7
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
7 commits
Select commit
Hold shift + click to select a range
ed6c4a8
Update Aikido pre-commit hook to use 'latest' version by default and …
ProxayFox 392d8ec
Add Aikido version check workflow to automate fallback version updates
ProxayFox 8837bcc
Add pinned version test script and scenarios configuration for aikido…
ProxayFox d562de9
Update README to clarify version management options for aikido-precommit
ProxayFox 551cd18
Initial plan
Copilot c67affb
Add warning messages when version fetch falls back to default
Copilot bb7a32b
Merge pull request #8 from ProxayFox/copilot/sub-pr-7
Datacom-Ayden 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,102 @@ | ||
| name: Check Aikido Scanner Version | ||
|
|
||
| on: | ||
| schedule: | ||
| # Run weekly on Mondays at 9:00 UTC | ||
| - cron: '0 9 * * 1' | ||
| workflow_dispatch: # Allow manual trigger | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| check-version: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Fetch upstream Aikido version | ||
| id: upstream | ||
| run: | | ||
| # Fetch the official Aikido install script | ||
| UPSTREAM_SCRIPT=$(curl -fsSL "https://raw.githubusercontent.com/AikidoSec/pre-commit/main/installation-samples/install-global/install-aikido-hook.sh") | ||
|
|
||
| # Extract VERSION from the script (format: VERSION="v1.0.116") | ||
| UPSTREAM_VERSION=$(echo "$UPSTREAM_SCRIPT" | grep -oP '^VERSION="\K[^"]+' | head -1) | ||
|
|
||
| if [ -z "$UPSTREAM_VERSION" ]; then | ||
| echo "Error: Could not extract version from upstream script" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "upstream_version=$UPSTREAM_VERSION" >> "$GITHUB_OUTPUT" | ||
| echo "Found upstream version: $UPSTREAM_VERSION" | ||
|
|
||
| - name: Get current pinned version | ||
| id: current | ||
| run: | | ||
| # Extract the fallback version from install.sh | ||
| CURRENT_VERSION=$(grep -oP 'FALLBACK_VERSION="\K[^"]+' src/aikido-precommit/install.sh | head -1) | ||
|
|
||
| if [ -z "$CURRENT_VERSION" ]; then | ||
| echo "Error: Could not extract FALLBACK_VERSION from install.sh" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "current_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT" | ||
| echo "Current pinned version: $CURRENT_VERSION" | ||
|
|
||
| - name: Compare versions | ||
| id: compare | ||
| run: | | ||
| UPSTREAM="${{ steps.upstream.outputs.upstream_version }}" | ||
| CURRENT="${{ steps.current.outputs.current_version }}" | ||
|
|
||
| if [ "$UPSTREAM" = "$CURRENT" ]; then | ||
| echo "Versions match ($CURRENT), no update needed" | ||
| echo "needs_update=false" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "Version mismatch: upstream=$UPSTREAM, current=$CURRENT" | ||
| echo "needs_update=true" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Update version in install.sh | ||
| if: steps.compare.outputs.needs_update == 'true' | ||
| run: | | ||
| UPSTREAM="${{ steps.upstream.outputs.upstream_version }}" | ||
| CURRENT="${{ steps.current.outputs.current_version }}" | ||
|
|
||
| # Update FALLBACK_VERSION in install.sh | ||
| sed -i "s/FALLBACK_VERSION=\"${CURRENT}\"/FALLBACK_VERSION=\"${UPSTREAM}\"/" src/aikido-precommit/install.sh | ||
|
|
||
| echo "Updated FALLBACK_VERSION from $CURRENT to $UPSTREAM" | ||
|
|
||
| - name: Create Pull Request | ||
| if: steps.compare.outputs.needs_update == 'true' | ||
| uses: peter-evans/create-pull-request@v7 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| commit-message: "chore(aikido-precommit): update fallback version to ${{ steps.upstream.outputs.upstream_version }}" | ||
| title: "chore(aikido-precommit): update fallback version to ${{ steps.upstream.outputs.upstream_version }}" | ||
| body: | | ||
| ## Automated Version Update | ||
|
|
||
| This PR updates the Aikido local scanner fallback version from `${{ steps.current.outputs.current_version }}` to `${{ steps.upstream.outputs.upstream_version }}`. | ||
|
|
||
| ### Source | ||
| Version extracted from [Aikido's official install script](https://github.com/AikidoSec/pre-commit/blob/main/installation-samples/install-global/install-aikido-hook.sh). | ||
|
|
||
| ### Notes | ||
| - Users with `version: "latest"` (default) will automatically get the new version | ||
| - Users with explicit version pins are unaffected | ||
| - The fallback version is used when the upstream script cannot be fetched | ||
|
|
||
| --- | ||
| *This PR was automatically created by the [aikido-version-check](.github/workflows/aikido-version-check.yml) workflow.* | ||
| branch: chore/aikido-version-update | ||
| delete-branch: true | ||
| labels: | | ||
| dependencies | ||
| automated |
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
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
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
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,21 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| echo "Testing: aikido-local-scanner pinned version installation" | ||
|
|
||
| # Check binary exists | ||
| if command -v aikido-local-scanner >/dev/null 2>&1; then | ||
| echo "✅ PASSED: aikido-local-scanner found" | ||
| else | ||
| echo "❌ FAILED: aikido-local-scanner not found" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # The pinned version test verifies that explicit versions work | ||
| # Note: We can't easily verify the exact version without aikido-local-scanner --version support | ||
| # but we verify the binary was successfully downloaded and installed | ||
| echo "✅ PASSED: Pinned version installation completed" | ||
|
|
||
| echo "" | ||
| echo "✅ All pinned-version tests passed!" |
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,11 @@ | ||
| { | ||
| "pinned-version": { | ||
| "image": "ubuntu:focal", | ||
| "features": { | ||
| "aikido-precommit": { | ||
| "version": "v1.0.100", | ||
| "setupGlobalHooks": 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.
When the curl command fails, there's no feedback to the user about why version resolution fell back. Consider logging a warning message before returning the fallback version to help users understand when/why they're not getting the latest version.