Skip to content
Open
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
126 changes: 42 additions & 84 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,90 +1,48 @@
# Goal - I have to Lint, Build, Test the code for Frontend & Backend
# then Push the images to DockerHub
# Goal: Build the image for devboard frontend and push to docker hub
name: CI

on:
push:
branches: [master]
push:
branches: [master]

jobs:
frontend:
# Github runner
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v7
code-lint:
Comment on lines 8 to +9

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Add explicit least-privilege permissions at workflow level.

Relying on default token scopes is broader than needed; define minimal permissions (for this workflow, contents: read is typically sufficient).

Suggested patch
 on: 
   push: 
     branches: [master]
 
+permissions:
+  contents: read
+
 jobs:
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
jobs:
frontend:
# Github runner
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v7
code-lint:
permissions:
contents: read
jobs:
code-lint:
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yml around lines 8 - 9, Add an explicit workflow-level
permissions block to the ci workflow so the GitHub token uses least privilege by
default. Update the workflow definition around the top-level jobs section in
ci.yml to set minimal permissions for this workflow, typically using the default
read-only contents scope, and keep any job-specific overrides only if a job
truly needs more access.

Source: Linters/SAST tools

runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the workflow and nearby lines with numbers.
git ls-files .github/workflows/ci.yml
wc -l .github/workflows/ci.yml
cat -n .github/workflows/ci.yml | sed -n '1,120p'

Repository: LondheShubham153/devboard

Length of output: 1682


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map uses references in the workflow and search for policy mentions.
rg -n "uses:\s*(actions/checkout|actions/setup-node|docker/login-action|docker/build-push-action)@" .github/workflows/ci.yml
rg -n "immutable commit SHA|pin.*SHA|supply-chain|actions/" .github/workflows .github README.md docs 2>/dev/null || true

Repository: LondheShubham153/devboard

Length of output: 1161


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Also inspect any workflow comments or references that may justify the choice.
sed -n '1,140p' .github/workflows/ci.yml | nl -ba

Repository: LondheShubham153/devboard

Length of output: 203


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Search for the exact action references and version pins.
rg -n "uses:\s*(actions/checkout|actions/setup-node|docker/login-action|docker/build-push-action)@" .github/workflows/ci.yml

Repository: LondheShubham153/devboard

Length of output: 361


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Print the workflow with line numbers and extract all action refs.
echo '--- ci.yml ---'
cat -n .github/workflows/ci.yml | sed -n '1,120p'
echo '--- action refs ---'
python3 - <<'PY'
import re, pathlib
text = pathlib.Path('.github/workflows/ci.yml').read_text()
for i, line in enumerate(text.splitlines(), 1):
    m = re.search(r'uses:\s*([^\s]+)', line)
    if m:
        print(f"{i}: {m.group(1)}")
PY

Repository: LondheShubham153/devboard

Length of output: 1797


Pin all workflow Actions to immutable commit SHAs.

  • .github/workflows/ci.yml: actions/checkout@v7, actions/setup-node@v4, docker/login-action@v4, docker/build-push-action@v7
  • .github/workflows/matrix.yml: actions/checkout@v7, actions/setup-go@v6
  • .github/workflows/cd.yml: actions/checkout@v7
🧰 Tools
🪛 zizmor (1.26.1)

[warning] 12-13: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)


[error] 13-13: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yml at line 13, The workflow actions are still using
version tags instead of immutable commit SHAs, so update each referenced action
in ci.yml, matrix.yml, and cd.yml to pin the exact SHA for actions/checkout,
actions/setup-node, actions/setup-go, docker/login-action, and
docker/build-push-action. Make the changes in the workflow definitions
themselves so the jobs continue to use the same actions but with SHA-pinned
references only.

Source: Linters/SAST tools


- name: Set up Node js
uses: actions/setup-node@v4
with:
node-version: 24

- name: Install node.js dependecies
working-directory: frontend
run: npm ci

- name: Run ESLint
working-directory: frontend
run: npm run lint

build-and-push:
needs: code-lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7

- name: Docker setup [Login to Docker]
uses: docker/login-action@v4
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Docker Build and Push
uses: docker/build-push-action@v7
with:
context: frontend
file: frontend/Dockerfile
push: true
tags: ${{ vars.DOCKERHUB_USERNAME }}/devboard-fe-master:latest

- name: Setup NodeJs
uses: actions/setup-node@v6
with:
node-version: '20'
cache: npm
cache-dependency-path: frontend/package-lock.json

- name: Install npm Packages
run: npm install
working-directory: frontend

- name: Run Linter
run: npm run lint
working-directory: frontend

- name: Run Tests
run: npm run test
working-directory: frontend

- name: Docker Setup [Login]
uses: docker/login-action@v4
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Docker Build and Push
uses: docker/build-push-action@v7
with:
context: ./frontend
push: true
tags: ${{ vars.DOCKERHUB_USERNAME }}/devboard-frontend:latest

backend:
# Github runner
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v7

- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: '1.23'
go-version-file: 'go.mod'
cache-dependency-path: go.sum

- name: Run Go Formatter
run: go fmt
working-directory: backend

- name: Run Go Vet
run: go vet
working-directory: backend

- name: Run Tests
run: go test
working-directory: backend

- name: Docker Setup [Login]
uses: docker/login-action@v4
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Docker Build and Push
uses: docker/build-push-action@v7
with:
context: ./backend
push: true
tags: ${{ vars.DOCKERHUB_USERNAME }}/devboard-backend:latest
deploy:
needs: [frontend,backend]
uses: ./.github/workflows/cd.yml
secrets: inherit