Skip to contentমূল লেখায় যান

Topic 06 · Securityটপিক 06 · Security

Security Automation and DevSecOps

A manual test finds a flaw once. An automated check looks for it again on every change. This page runs four kinds of security checks from the command line and then puts them into a CI pipeline, so that a pull request with a known flaw fails before anyone merges it.

8 min read8 মিনিটে পড়া যায় · 6 sections6টি সেকশন · 15 sources15টি সোর্স · updated Nov 2026আপডেট: Nov 2026

Which scan fails the build?কোন স্ক্যান বিল্ড ব্যর্থ করে?

Run four scanners and see which exit codes stop the pipeline. Then switch on the strict flags.চারটা স্ক্যানার চালান আর দেখুন কোন exit code পাইপলাইন থামায়। তারপর কঠোর ফ্ল্যাগ চালু করুন।

2 min2 মিনিট7 steps7টি ধাপ
  • Jobজব—
  • Failing scannersব্যর্থ স্ক্যানার0 / 4
commit · PRকমিট · PRSemgrepSemgrepSASTSASTTrivyTrivySCASCAGitleaksGitleakssecretসিক্রেটZAPZAPDASTDASTCI jobCI জবjob: waitingজব: অপেক্ষা

You’ll learnআপনি শিখবেন

  • The default exit code of each scannerপ্রতিটা স্ক্যানারের ডিফল্ট exit code
  • Which flags make Semgrep and Trivy failকোন ফ্ল্যাগ Semgrep ও Trivy-কে ব্যর্থ করায়
  • How a green job can hide findingsসবুজ জব কীভাবে সমস্যা লুকাতে পারে
  • Why Gitleaks needs the full historyGitleaks-এর কেন পুরো history দরকার

In plain words

Four kinds of automated checks cover different parts of an application:

  • SAST (static application security testing) analyzes source code, or a compiled version of it, to find security flaws Source 1সোর্স 1. OWASP notes that SAST feedback can save time and effort compared with finding vulnerabilities later in the development cycle Source 1সোর্স 1. This page uses Semgrep.
  • Component analysis identifies the risk from third-party and open-source components; its software-only subset is commonly called software composition analysis (SCA) Source 3সোর্স 3. It matters because an organization that uses open-source components takes responsibility for code it did not write Source 3সোর্স 3. This page uses Trivy, which also finds secrets and misconfigurations Source 7সোর্স 7.
  • Secret scanning looks for passwords, API keys, and tokens. Gitleaks finds them in git repositories, in files, and in anything piped to it on standard input Source 11সোর্স 11.
  • DAST (dynamic application security testing) tools scan a running web application, normally from the outside, for flaws such as cross-site scripting and SQL injection Source 2সোর্স 2. This page uses the ZAP baseline scan Source 12সোর্স 12.

A CI pipeline decides by exit code. On GitHub Actions, the runner reports each step as failed or succeeded from the exit code of its script Source 13সোর্স 13. Two of these tools, Semgrep and Trivy, return 0 even when they find issues, until you tell them otherwise Source 4সোর্স 4 Source 8সোর্স 8. Setting the exit codes right is the main job of this page.

সহজ English

Four kinds of automatic checks look at different parts of an app:

A CI pipeline decides by exit code: the number a program returns when it ends. On GitHub Actions, a step fails or passes based on that number Source 13সোর্স 13. Two of these tools, Semgrep and Trivy, return 0 (pass) even when they find problems, unless you tell them otherwise Source 4সোর্স 4 Source 8সোর্স 8. Setting that number right is the main job of this page.

বাংলা ব্যাখ্যা

চার ধরনের স্বয়ংক্রিয় যাচাই একটা app-এর আলাদা আলাদা অংশ দেখে:

  • SAST source code পড়ে security-র দুর্বলতা খোঁজে Source 1সোর্স 1। OWASP বলে, পরে দুর্বলতা খোঁজার তুলনায় এতে সময় আর পরিশ্রম বাঁচে Source 1সোর্স 1। এই পেজে Semgrep ব্যবহার করা হয়েছে।
  • Component analysis, যাকে প্রায়ই SCA বলা হয়, app যে বাইরের আর open-source অংশ ব্যবহার করে, সেগুলোর ঝুঁকি খুঁজে বের করে Source 3সোর্স 3। এটা জরুরি, কারণ যে দল open-source code ব্যবহার করে, সে এমন code-এর দায়িত্ব নেয়, যেটা সে নিজে লেখেনি Source 3সোর্স 3। এই পেজে Trivy ব্যবহার করা হয়েছে, যেটা secret আর ভুল setting-ও খুঁজে পায় Source 7সোর্স 7।
  • Secret scanning password, API key আর token খোঁজে। Gitleaks এগুলো git project-এ, ফাইলে, আর pipe করে দেওয়া লেখায় খুঁজে পায় Source 11সোর্স 11।
  • DAST tool চালু থাকা একটা web app-কে, সাধারণত বাইরে থেকে, cross-site scripting আর SQL injection-এর মতো দুর্বলতার জন্য পরীক্ষা করে Source 2সোর্স 2। এই পেজে ZAP baseline scan ব্যবহার করা হয়েছে Source 12সোর্স 12।

CI pipeline সিদ্ধান্ত নেয় exit code দিয়ে: একটা program শেষ হওয়ার সময় যে সংখ্যা ফেরত দেয়। GitHub Actions-এ একটা step pass না fail, সেটা ঠিক হয় এই সংখ্যা দিয়ে Source 13সোর্স 13। এর মধ্যে দুটো tool, Semgrep আর Trivy, সমস্যা পেলেও 0 (pass) ফেরত দেয়, যদি না আপনি অন্যভাবে বলেন Source 4সোর্স 4 Source 8সোর্স 8। এই সংখ্যা ঠিকভাবে সেট করাই এই পেজের মূল কাজ।

How it works

CheckLooks atCommandDefault exit codeTo fail on findings
SASTSource codesemgrep scan --config "p/default" Source 5সোর্স 50 even when there are findings Source 4সোর্স 4Add --error Source 5সোর্স 5
Dependencies, secrets, misconfigurationsFiles of a projecttrivy fs --scanners vuln,secret,misconfig . Source 7সোর্স 70 even when issues are found Source 8সোর্স 8Add --exit-code 1, and --severity to choose the levels Source 8সোর্স 8 Source 9সোর্স 9
Secrets in the historyEvery commit of a git repositorygitleaks git -v Source 11সোর্স 111 when leaks are found Source 11সোর্স 11Nothing to add
DAST (passive)The running web appzap-baseline.py -t <url> Source 12সোর্স 121 for a FAIL, 2 for warnings only Source 12সোর্স 12Already non-zero. To fail only on chosen rules, set them to FAIL in a config file and add -I Source 12সোর্স 12

The tools in more detail

In the pipeline

On GitHub Actions, bash and sh steps run with set -e, so the first failing command stops the script, and the step's status follows the exit code Source 13সোর্স 13. A failed step fails the job, unless the step sets continue-on-error: true Source 13সোর্স 13. actions/checkout fetches a single commit by default; fetch-depth: 0 fetches the whole history Source 14সোর্স 14, which Gitleaks needs to scan every commit.

সহজ English

The four tools.

In the pipeline. On GitHub Actions, a shell step stops at the first failing command, and the step's result follows the exit code Source 13সোর্স 13. A failed step fails the job, unless the step has continue-on-error: true Source 13সোর্স 13. actions/checkout fetches only the last commit by default; fetch-depth: 0 fetches the whole history Source 14সোর্স 14, which Gitleaks needs to check every commit.

বাংলা ব্যাখ্যা

চারটা tool।

  • Semgrep (SAST)। semgrep scan --config "p/default" ডিফল্ট rule দিয়ে scan করে Source 5সোর্স 5। সমস্যা পেলেও এটা 0 ফেরত দেয় Source 4সোর্স 4। কিছু পেলে 1 ফেরত দেওয়াতে --error যোগ করুন Source 5সোর্স 5। semgrep scan Semgrep account ছাড়াই চলে Source 4সোর্স 4। Private code-এ --config auto এড়িয়ে চলুন: এটা আপনার project-এর URL Semgrep Registry-তে পাঠায় Source 5সোর্স 5।
  • Trivy (SCA আর আরও কিছু)। Trivy container image, folder, git project আর আরও কিছু scan করে। এটা ব্যবহৃত software, পরিচিত দুর্বলতা, infrastructure ফাইলের ভুল setting, secret আর license খুঁজে পায় Source 7সোর্স 7। সমস্যা পেলেও এটা 0 ফেরত দেয়; --exit-code 1 সেটা বদলায় Source 8সোর্স 8, আর --severity HIGH,CRITICAL শুধু ওই মাত্রাগুলো রাখে Source 9সোর্স 9।
  • Gitleaks (secret)। gitleaks git -v একটা git project-এর প্রতিটা commit scan করে Source 11সোর্স 11। এটা প্রতিটা commit-এর পরিবর্তন পড়ে, তাই পরের কোনো commit-এ মুছে ফেলা secret-ও খুঁজে পায় Source 11সোর্স 11। Leak পেলে এটা 1 ফেরত দেয় Source 11সোর্স 11। --redact এর লেখায় secret লুকিয়ে রাখে Source 11সোর্স 11।
  • ZAP baseline (DAST)। এটা ডিফল্টভাবে এক মিনিট site ঘুরে দেখে, তারপর passive scan শেষ হওয়ার অপেক্ষা করে। এটা site-এ আক্রমণ করে না, আর বড়জোর কয়েক মিনিট লাগে Source 12সোর্স 12। FAIL থাকলে এটা 1 ফেরত দেয়, আর শুধু warning থাকলে 2, তাই এটা এমনিতেই pipeline fail করায় Source 12সোর্স 12। কোন rule FAIL ধরা হবে, সেটা একটা config ফাইল ঠিক করে, আর -I warning-এ fail হওয়া বন্ধ করে Source 12সোর্স 12।

Pipeline-এ। GitHub Actions-এ shell step প্রথম ব্যর্থ command-এ থেমে যায়, আর step-এর ফলাফল exit code মেনে চলে Source 13সোর্স 13। একটা step ব্যর্থ হলে পুরো job ব্যর্থ হয়, যদি না step-এ continue-on-error: true থাকে Source 13সোর্স 13। actions/checkout ডিফল্টভাবে শুধু শেষ commit আনে; fetch-depth: 0 পুরো history আনে Source 14সোর্স 14, যেটা Gitleaks-এর প্রতিটা commit যাচাই করতে লাগে।

In practice

1. Run each tool on your own machine. Start in the root of a project that you own.

# SAST: install Semgrep with pipx, the recommended way, then scan
pipx install semgrep
semgrep scan --config "p/default" --error

# Dependencies, secrets, and misconfigurations, with the official Trivy image
docker run --rm -v "$PWD":/src aquasec/trivy:0.76.2 \
  fs --scanners vuln,secret,misconfig --exit-code 1 /src

# Secrets in every commit, with the official Gitleaks image
docker run --rm -v "$PWD":/path zricethezav/gitleaks:v8.30.1 git -v --redact /path

Semgrep's install line and scan command come from its docs Source 4সোর্স 4 Source 5সোর্স 5. Trivy's official images are on Docker Hub, GHCR, and ECR, and its docs pin a version in their own example Source 10সোর্স 10. The Gitleaks image and its argument order come from its README Source 11সোর্স 11. Then echo $? shows the exit code of the last command.

2. Scan the practice app with ZAP. With the lab running, start the baseline scan on the same Docker network, so that it reaches Juice Shop by name. Mount the current folder to get the HTML report Source 12সোর্স 12:

docker run --rm --network lab -v "$(pwd)":/zap/wrk/:rw -t ghcr.io/zaproxy/zaproxy:stable \
  zap-baseline.py -t http://juice:3000 -r zap-report.html

3. Run the checks on every pull request. This GitHub Actions workflow is the tutorial's own example. It is built from the Semgrep sample configuration Source 6সোর্স 6, the commands above, and fetch-depth: 0 for Gitleaks Source 14সোর্স 14:

name: security-checks
on:
  pull_request: {}
permissions:
  contents: read
jobs:
  sast:
    runs-on: ubuntu-latest
    container:
      image: semgrep/semgrep
    steps:
      - uses: actions/checkout@v7
      - run: semgrep scan --config "p/default" --error

  dependencies-and-secrets:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
        with:
          fetch-depth: 0
      - name: Dependencies, secrets, and misconfigurations (Trivy)
        run: |
          docker run --rm -v "$PWD":/src aquasec/trivy:0.76.2 \
            fs --scanners vuln,secret,misconfig --severity HIGH,CRITICAL --exit-code 1 /src
      - name: Secrets in every commit (Gitleaks)
        run: docker run --rm -v "$PWD":/path zricethezav/gitleaks:v8.30.1 git -v --redact /path

The tutorial's advice: run the ZAP baseline in a later job, against a test deployment of the app, not against production. For the basics of pipelines, see CI/CD Pipelines.

4. Stop secrets before they are committed. Gitleaks also works as a pre-commit hook. Put this in .pre-commit-config.yaml, run pre-commit autoupdate to move to the latest release, and then pre-commit install Source 11সোর্স 11:

repos:
  - repo: https://github.com/gitleaks/gitleaks
    rev: v8.30.1
    hooks:
      - id: gitleaks

সহজ English

  1. Run each tool on your own computer. Start in the main folder of a project you own. The Technical view has the commands: Semgrep, installed with pipx as its docs recommend Source 4সোর্স 4, Trivy and Gitleaks from their official Docker images Source 10সোর্স 10 Source 11সোর্স 11. After each one, echo $? shows its exit code.
  2. Scan the practice app with ZAP. With the lab running, start the baseline scan on the same Docker network, so that it can reach Juice Shop by name. Mount the current folder to get the HTML report Source 12সোর্স 12.
  3. Run the checks on every pull request. The Technical view has a GitHub Actions workflow. It is the tutorial's own example, built from the Semgrep sample Source 6সোর্স 6, the same commands, and fetch-depth: 0 so that Gitleaks sees every commit Source 14সোর্স 14. The tutorial's advice: run the ZAP baseline later, against a test copy of the app, never against the live site. For the basics of pipelines, see CI/CD Pipelines.
  4. Stop secrets before they are committed. Gitleaks also works as a pre-commit hook. Put the snippet from the Technical view in .pre-commit-config.yaml, run pre-commit autoupdate to get the latest version, and then pre-commit install Source 11সোর্স 11.

বাংলা ব্যাখ্যা

  1. প্রতিটা tool নিজের computer-এ চালান। আপনার নিজের একটা project-এর মূল folder থেকে শুরু করুন। Command-গুলো Technical view-এ আছে: Semgrep, এর docs-এর পরামর্শমতো pipx দিয়ে install করা Source 4সোর্স 4, আর Trivy ও Gitleaks তাদের অফিসিয়াল Docker image থেকে Source 10সোর্স 10 Source 11সোর্স 11। প্রতিটার পরে echo $? তার exit code দেখায়।
  2. ZAP দিয়ে প্র্যাকটিস app scan করুন। ল্যাব চালু রেখে একই Docker network-এ baseline scan শুরু করুন, যাতে এটা নাম দিয়ে Juice Shop-এ পৌঁছাতে পারে। HTML রিপোর্ট পেতে বর্তমান folder mount করুন Source 12সোর্স 12।
  3. প্রতিটা pull request-এ যাচাইগুলো চালান। Technical view-এ একটা GitHub Actions workflow আছে। এটা টিউটোরিয়ালের নিজের উদাহরণ, Semgrep-এর নমুনা Source 6সোর্স 6, একই command-গুলো, আর fetch-depth: 0 দিয়ে বানানো, যাতে Gitleaks প্রতিটা commit দেখতে পায় Source 14সোর্স 14। টিউটোরিয়ালের পরামর্শ: ZAP baseline পরে চালান, app-এর একটা test কপির ওপর, কখনো live site-এ নয়। Pipeline-এর মূল বিষয়গুলোর জন্য CI/CD Pipelines দেখুন।
  4. Commit-এর আগেই secret আটকান। Gitleaks একটা pre-commit hook হিসেবেও কাজ করে। Technical view-এর অংশটা .pre-commit-config.yaml-এ রাখুন, সর্বশেষ version পেতে pre-commit autoupdate চালান, তারপর pre-commit install Source 11সোর্স 11।

Common mistakes

সহজ English

বাংলা ব্যাখ্যা

  • এমন সবুজ pipeline, যেটা কখনো fail করে না। সমস্যা পেলেও Semgrep আর Trivy 0 ফেরত দেয়। --error আর --exit-code 1 ছাড়া দুর্বলতা নিয়েই job pass হয়ে যায় Source 4সোর্স 4 Source 8সোর্স 8।
  • Secret scanning-এর জন্য শুধু শেষ commit আনা। actions/checkout ডিফল্টভাবে একটা commit আনে Source 14সোর্স 14, তাই যে secret যোগ করে পরে মুছে ফেলা হয়েছে, Gitleaks সেটা ধরতে পারবে না।
  • Leak হওয়া secret মুছে দিয়েই থেমে যাওয়া। Secret-টা history-তে থেকে যায়, আর gitleaks git সেখানেই সেটা খুঁজে পায়, কারণ এটা প্রতিটা commit-এর পরিবর্তন পড়ে Source 11সোর্স 11। OWASP বলে, ফাঁস হওয়া secret সঙ্গে সঙ্গে বাতিল করুন, নতুন একটা বানান, আর যেখানে ফাঁস হয়েছে সেখান থেকে সরিয়ে দিন Source 15সোর্স 15।
  • অভ্যাসবশত hook এড়িয়ে যাওয়া। SKIP=gitleaks ওই commit-এর জন্য hook বন্ধ করে দেয় Source 11সোর্স 11। এটা শুধু সত্যিকারের ভুয়া alert-এর জন্য রাখুন।
  • Private code-এ --config auto ব্যবহার করা। এটা আপনার project-এর URL Semgrep Registry-তে পাঠায় Source 5সোর্স 5।
  • Baseline-কে পূর্ণ টেস্ট ধরে নেওয়া। Baseline scan site-এ আক্রমণ করে না Source 12সোর্স 12। Web application security-এর active scan-এর প্রয়োজন তবুও থাকে।

What a tester can check

Tutorial advice

This list is the tutorial's own advice, not a fact from a source.

  • Each check fails on purpose once. Add a known test secret or a string-built query on a branch, open a pull request, and confirm that the pipeline goes red. Then remove it.
  • Tool versions are pinned and updated on purpose, so that a new release cannot change the results without anyone noticing.
  • Every suppressed finding has a reason written next to it, with a name and a date.
  • Reports are kept as build artifacts, so that a later reviewer can see what was found and when.
  • Findings reach a person. A failed check opens or updates a ticket, not only a red mark that someone reruns.

সহজ English

Tutorial advice

This list is the tutorial's own advice, not a fact from a source.

  • Make each check fail on purpose once. On a test branch, add a fake secret or a query glued from text, open a pull request, and confirm that the pipeline turns red. Then remove it.
  • Pin the tool versions and update them on purpose, so that a new release cannot change the results without anyone noticing.
  • Every hidden finding has a reason written next to it, with a name and a date.
  • Keep the reports with each build, so that someone can later see what was found and when.
  • Findings reach a person. A failed check opens or updates a ticket, not only a red mark that someone runs again.

বাংলা ব্যাখ্যা

Tutorial advice

এই তালিকা টিউটোরিয়ালের নিজের পরামর্শ, কোনো source থেকে নেওয়া তথ্য নয়।

  • প্রতিটা যাচাই একবার ইচ্ছা করে fail করান। একটা test branch-এ একটা নকল secret বা text জুড়ে বানানো query যোগ করুন, pull request খুলুন, আর নিশ্চিত হন যে pipeline লাল হয়। তারপর সেটা সরিয়ে দিন।
  • Tool-এর version নির্দিষ্ট করে রাখুন আর ভেবেচিন্তে update করুন, যাতে নতুন release কারো অজান্তে ফলাফল বদলাতে না পারে।
  • লুকানো প্রতিটা finding-এর পাশে কারণ লেখা থাকবে, একটা নাম আর তারিখসহ।
  • রিপোর্টগুলো রেখে দিন প্রতিটা build-এর সঙ্গে, যাতে পরে কেউ দেখতে পারেন কী পাওয়া গিয়েছিল আর কখন।
  • Finding একজন মানুষের কাছে পৌঁছায়। ব্যর্থ যাচাই একটা ticket খোলে বা update করে, শুধু একটা লাল চিহ্ন নয়, যেটা কেউ আবার চালিয়ে দেন।

Key words

TermMeaning
DevSecOpsBuilding security checks into the development and delivery pipeline.
SASTStatic application security testing: analysing source code for security flaws.
DASTDynamic application security testing: scanning a running application from the outside.
SCASoftware composition analysis: finding risk in third-party and open-source components.
CVEAn entry in the public list of known vulnerabilities.
SBOMSoftware bill of materials: the list of components that a piece of software contains.
Secret scanningSearching code and history for passwords, keys, and tokens.
Exit codeThe number a program returns when it ends. 0 means success.
Baseline scanZAP's short passive scan that spiders a site without attacking it.
Pre-commit hookA check that runs before git records a commit.
  1. [1]
    Source Code Analysis Tools

    OWASP Foundation · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  2. [2]
    Vulnerability Scanning Tools

    OWASP Foundation · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  3. [3]
    Component Analysis

    OWASP Foundation · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  4. [4]
    Local scans with Semgrep

    Semgrep documentation · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  5. [5]
    CLI reference

    Semgrep documentation · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  6. [6]
    Sample continuous integration (CI) configurations

    Semgrep documentation · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  7. [7]
    trivy (README)

    Aqua Security on GitHub · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  8. [8]
    Others (Exit Code)

    Trivy documentation · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  9. [9]
    Filtering

    Trivy documentation · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  10. [10]
    Installation

    Trivy documentation · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  11. [11]
    gitleaks (README)

    Gitleaks on GitHub · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  12. [12]
    Baseline Scan

    ZAP documentation · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  13. [13]
    Workflow syntax for GitHub Actions

    GitHub Docs · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  14. [14]
    checkout (README)

    GitHub Actions on GitHub · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  15. [15]
    Secrets Management Cheat Sheet

    OWASP Cheat Sheet Series · accessed 2026-11-15দেখা হয়েছে: 2026-11-15