-
Notifications
You must be signed in to change notification settings - Fork 60
Release Chef Integration v1.0.0 #877
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
Open
stas-schaller
wants to merge
30
commits into
master
Choose a base branch
from
release/integration/chef/v1.0.0
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
f9b0fd3
Adding Keeper-Chef Integration
yash-metron c08e3e7
Updated README file
yash-metron d959323
Updated Readme.md file.
yash-metron 4d07b59
Address review comments
yash-metron c1b2b2f
Update metadata
yash-metron e3b3d51
Merge pull request #9 from metron-labs/chef_integration_dev
yash-metron 0f3df50
Upated license in metadata
yash-metron cfc3ed6
Added sensitive true to hide output logs
yash-metron de592ff
Added github action to publish chef integration.
yash-metron ec8ebd3
Updated spec files.
yash-metron 4277c42
Updated Chef resources as per the new Chef version.
yash-metron 6b00fc4
Updated Chef commands in publish-chef-supermarket.yml
ysolanki-ks a4e2e61
Addressed the review comments given by the Keeper team.
ysolanki-ks e16bf43
Added ruby to resuable sbom, updated secrets, updated knife commands …
stas-schaller 83158e3
Merge pull request #15 from stas-schaller/workflow-and-readme-additions
yash-metron ddcf5e1
Resolved merge conflict in reusable sbom
stas-schaller f18e952
Fix: Resolve bugs in Chef integration
yash-metron 57b4205
Merge branch 'master' into release/integration/chef/v1.0.0
stas-schaller ea0df27
Merge Chef integration v1.0.0 from metron-labs
stas-schaller 4b04f13
refactor: replace reusable SBOM workflow with inline scanning in Chef…
stas-schaller 83d96af
fix: add proper knife authentication for Chef Supermarket publishing
stas-schaller 3a32d69
fix: add explicit permissions to workflow jobs (CodeQL alerts 113, 15…
stas-schaller 5600696
revert: remove Ruby support from reusable SBOM workflow
stas-schaller 1be1b4d
chore: update Chef cookbook version to 1.0.0 and add repository URLs
stas-schaller 39b18e0
addressed cookbook execution issues on windows
amuley-ks a239ccd
updated recipies and resources
adityam-metron e7ac754
updated logic to install python automatically on windows
adityam-metron 5e4a41a
fixed the python installation on windows, fixed linting issue
adityam-metron 685f61e
Merge branch 'Keeper-Security:master' into fix-chef-cookbook-executio…
adityam-metron 3132ee1
Merge pull request #882 from metron-labs/fix-chef-cookbook-execution-…
stas-schaller 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
Some comments aren't visible on the classic Files Changed page.
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,239 @@ | ||
| name: Publish to Chef Supermarket | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| publish: | ||
| description: 'Publish to Chef Supermarket (uncheck to build only)' | ||
| required: false | ||
| default: 'true' | ||
| type: boolean | ||
|
|
||
| jobs: | ||
| get-version: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| outputs: | ||
| version: ${{ steps.extract-version.outputs.version }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Extract version from metadata.rb | ||
| id: extract-version | ||
| working-directory: ./integration/keeper_secrets_manager_chef/cookbooks/keeper_secrets_manager | ||
| run: | | ||
| echo "Detecting Chef cookbook version..." | ||
| if [ -f "metadata.rb" ]; then | ||
| VERSION=$(grep "version" "metadata.rb" | awk '{print $2}' | tr -d "'\"") | ||
| echo "Detected version: ${VERSION}" | ||
| else | ||
| VERSION="1.0.0" | ||
| echo "Could not detect version, using default: ${VERSION}" | ||
| fi | ||
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | ||
|
|
||
|
|
||
| generate-sbom: | ||
| name: Generate SBOM | ||
| needs: get-version | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| timeout-minutes: 10 | ||
|
|
||
| defaults: | ||
| run: | ||
| working-directory: ./integration/keeper_secrets_manager_chef/cookbooks/keeper_secrets_manager | ||
|
|
||
| steps: | ||
| - name: Get the source code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Ruby | ||
| uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: '3.2.4' | ||
| working-directory: ./integration/keeper_secrets_manager_chef/cookbooks/keeper_secrets_manager | ||
|
|
||
| - name: Install Syft and Manifest CLI | ||
| run: | | ||
| echo "Installing Syft v1.18.1..." | ||
| curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /tmp/bin v1.18.1 | ||
| export PATH="/tmp/bin:$PATH" | ||
|
|
||
| echo "Installing Manifest CLI v0.18.3..." | ||
| curl -sSfL https://raw.githubusercontent.com/manifest-cyber/cli/main/install.sh | sh -s -- -b /tmp/bin v0.18.3 | ||
|
|
||
| - name: Generate and publish SBOM | ||
| env: | ||
| MANIFEST_TOKEN: ${{ secrets.MANIFEST_TOKEN }} | ||
| PROJECT_VERSION: ${{ needs.get-version.outputs.version }} | ||
| run: | | ||
| export PATH="/tmp/bin:$PATH" | ||
|
|
||
| echo "Creating Syft configuration for Ruby scanning..." | ||
| cat > syft-config.yaml << 'EOF' | ||
| package: | ||
| search: | ||
| scope: all-layers | ||
| cataloger: | ||
| enabled: true | ||
| java: | ||
| enabled: false | ||
| python: | ||
| enabled: false | ||
| nodejs: | ||
| enabled: false | ||
| ruby: | ||
| enabled: true | ||
| search-unindexed-archives: true | ||
| search-indexed-archives: true | ||
| EOF | ||
|
|
||
| echo "Generating SBOM with Manifest CLI..." | ||
| /tmp/bin/manifest sbom . \ | ||
| --generator=syft \ | ||
| --name=keeper-secrets-manager-chef \ | ||
| --version=${PROJECT_VERSION} \ | ||
| --output=spdx-json \ | ||
| --file=chef-sbom.json \ | ||
| --api-key=${MANIFEST_TOKEN} \ | ||
| --publish=true \ | ||
| --asset-label=application,sbom-generated,ruby,chef \ | ||
| --generator-config=syft-config.yaml | ||
|
|
||
| echo "SBOM generated and uploaded successfully: chef-sbom.json" | ||
|
|
||
| - name: Archive SBOM | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: sbom-chef-${{ needs.get-version.outputs.version }} | ||
| path: ./integration/keeper_secrets_manager_chef/cookbooks/keeper_secrets_manager/chef-sbom.json | ||
| retention-days: 90 | ||
|
|
||
|
|
||
| publish-chef-supermarket: | ||
| needs: [get-version, generate-sbom] | ||
| if: ${{ github.event.inputs.publish == 'true' }} | ||
| runs-on: ubuntu-latest | ||
| environment: prod | ||
| permissions: | ||
| contents: read | ||
| timeout-minutes: 20 | ||
|
|
||
| defaults: | ||
| run: | ||
| working-directory: ./integration/keeper_secrets_manager_chef/cookbooks/keeper_secrets_manager | ||
|
|
||
| steps: | ||
| - name: Get the source code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Ruby | ||
| uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: '3.2.4' | ||
|
|
||
| - name: Retrieve secrets from KSM | ||
| id: ksmsecrets | ||
| uses: Keeper-Security/ksm-action@master | ||
| with: | ||
| keeper-secret-config: ${{ secrets.KSM_CHEF_SUPERMARKET_CONFIG }} | ||
| secrets: | | ||
| b9vSxs5Dn-yJTPYr7Yvfmg/field/login > CHEF_USER | ||
| b9vSxs5Dn-yJTPYr7Yvfmg/file/keepersecurity.pem > file:keepersecurity.pem | ||
| b9vSxs5Dn-yJTPYr7Yvfmg/custom_field/server_url > CHEF_SERVER_URL | ||
|
|
||
| - name: Configure knife authentication | ||
| run: | | ||
| mkdir -p ~/.chef | ||
|
|
||
| # Move the client key from workspace to ~/.chef | ||
| mv "${{ github.workspace }}/keepersecurity.pem" ~/.chef/client.pem | ||
| chmod 600 ~/.chef/client.pem | ||
|
|
||
| # Verify key file exists and has correct permissions | ||
| ls -la ~/.chef/client.pem | ||
| echo "Client key file created with permissions: $(stat -f '%A' ~/.chef/client.pem)" | ||
|
|
||
| # Create knife config | ||
| cat > ~/.chef/config.rb << EOF | ||
| node_name '${{ steps.ksmsecrets.outputs.CHEF_USER }}' | ||
| client_key File.expand_path('~/.chef/client.pem') | ||
| chef_server_url '${{ steps.ksmsecrets.outputs.CHEF_SERVER_URL }}' | ||
| cookbook_path [File.expand_path('.')] | ||
| EOF | ||
|
|
||
| echo "Knife configuration created:" | ||
| cat ~/.chef/config.rb | ||
|
|
||
| - name: Get current version and validate | ||
| id: version | ||
| run: | | ||
| if [[ -f "metadata.rb" ]]; then | ||
| VERSION=$(grep "version" metadata.rb | awk '{print $2}' | tr -d "'\"") | ||
| echo "current_version=$VERSION" >> $GITHUB_OUTPUT | ||
| echo "Current version: $VERSION" | ||
| else | ||
| echo "Error: metadata.rb not found" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Check if version already exists on Chef Supermarket | ||
| env: | ||
| VERSION: ${{ steps.version.outputs.current_version }} | ||
| run: | | ||
| echo "Checking if version $VERSION exists on Supermarket..." | ||
| RESULT=$(curl -s "https://supermarket.chef.io/api/v1/cookbooks/keeper_secrets_manager/versions/${VERSION}") | ||
| if echo "$RESULT" | grep -q '"version"'; then | ||
| echo "Error: Version $VERSION already exists on Chef Supermarket!" | ||
| exit 1 | ||
| fi | ||
| echo "Version $VERSION is available for publishing" | ||
|
|
||
| - name: Install Chef Workstation | ||
| run: | | ||
| echo "Installing Chef Workstation..." | ||
| curl https://omnitruck.chef.io/install.sh | sudo bash -s -- -P chef-workstation | ||
| chef --version | ||
|
|
||
| - name: Run linting (Cookstyle) | ||
| run: | | ||
| echo "Running cookstyle..." | ||
| cookstyle || exit 1 | ||
|
|
||
| - name: Run ChefSpec tests | ||
| run: | | ||
| echo "Running ChefSpec tests..." | ||
| rspec || exit 1 | ||
|
|
||
| - name: Publish to Chef Supermarket | ||
| env: | ||
| VERSION: ${{ steps.version.outputs.current_version }} | ||
| run: | | ||
| echo "Publishing to Chef Supermarket..." | ||
| echo "Using knife configuration from ~/.chef/config.rb" | ||
|
|
||
| # Verify knife configuration | ||
| knife ssl check || echo "Warning: SSL check failed, but continuing..." | ||
|
|
||
| # Share cookbook to Supermarket | ||
| knife supermarket share keeper_secrets_manager "Utilities" \ | ||
| --supermarket-site https://supermarket.chef.io \ | ||
| --cookbook-path . | ||
|
|
||
| echo "Successfully published version $VERSION to Chef Supermarket!" | ||
|
|
||
| - name: Create release summary | ||
| env: | ||
| VERSION: ${{ steps.version.outputs.current_version }} | ||
| run: | | ||
| echo "## Chef Cookbook Published Successfully!" >> $GITHUB_STEP_SUMMARY | ||
| echo "**Version:** $VERSION" >> $GITHUB_STEP_SUMMARY | ||
| echo "**Cookbook:** keeper_secrets_manager" >> $GITHUB_STEP_SUMMARY | ||
| echo "**Supermarket URL:** https://supermarket.chef.io/cookbooks/keeper_secrets_manager" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "### Validation Results" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Cookstyle: Passed" >> $GITHUB_STEP_SUMMARY | ||
| echo "- ChefSpec Tests: Passed" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Cookbook Build: Successful" >> $GITHUB_STEP_SUMMARY | ||
| echo "- Supermarket Publish: Successful" >> $GITHUB_STEP_SUMMARY | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.