Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions .github/actions/my-cli-action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: "Setup MyCLI"
description: "Installs MyCLI and adds it to the PATH"
author: "Christianncode"

inputs:
version:
description: "The CLI version to install"
required: false
default: "latest"
runs:
using: "node16"
main: "index.js"
20 changes: 20 additions & 0 deletions .github/actions/my-cli-action/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const core = require("@actions/core");
const {execSync} = require("child_process");

async function run() {
try {
const version = core.getInput("version") || "latest";

console.log(`Installing MyCLI version: ${version}...`);

execSync(`curl -fsSL https://cli.example.com/install.sh | sh`, {
stdio: "inherit",
});

console.log("MyCLI installed successfully.");
} catch (error) {
core.setFailed(`Installation failed: ${error.message}`);
}
}

run();
24 changes: 24 additions & 0 deletions .github/workflows/test-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Test MyCLI Setup

on:
push:
branches:
- main
- feature/*

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install MyCLI
uses: ./.github/actions/my-cli-action
with:
version: "1.2.3"

- name: Verify CLI Installation
run: |
echo "Checking MyCLI version..."
mycli --version
Comment on lines +11 to +24

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium test

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 10 months ago

To fix the problem, add a permissions block to the workflow file .github/workflows/test-cli.yml. The block should be placed at the top level of the workflow (parallel to name and on) to restrict permissions for all jobs in the workflow. The recommended minimum for most workflows is contents: read, which allows jobs to read repository contents but not write or perform other privileged actions. This addresses the principle of least privilege, ensuring that the workflow cannot perform unnecessary actions with the GITHUB_TOKEN. No imports or method changes are necessary; just insert the YAML block as described.

Suggested changeset 1
.github/workflows/test-cli.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/test-cli.yml b/.github/workflows/test-cli.yml
--- a/.github/workflows/test-cli.yml
+++ b/.github/workflows/test-cli.yml
@@ -1,4 +1,6 @@
 name: Test MyCLI Setup
+permissions:
+  contents: read
 
 on:
   push:
EOF
@@ -1,4 +1,6 @@
name: Test MyCLI Setup
permissions:
contents: read

on:
push:
Copilot is powered by AI and may make mistakes. Always verify output.
2 changes: 1 addition & 1 deletion .github/workflows/workflow-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: actions/checkout@v4

- name: Call Greeting Workflow
uses: ./.github/workflows/utilities/composite-workflow
uses: ./.github/actions/composite-workflow
with:
name: "Environment: ${{ vars.ENVIRONMENT_NAME }}"
message: "Hola"
Loading