Your CI/CD pipeline is green. All automated tests pass. The team is ready to deploy.
But here is the problem:
A green functional test suite does not necessarily mean the application is secure.
Functional automation usually answers questions such as:
- Does the feature work?
- Can the user complete the expected workflow?
- Does the API return the expected response?
- Did the latest change break an existing feature?
Security testing asks a different set of questions:
- Did someone accidentally commit an API key?
- Are we using a dependency with a known vulnerability?
- Can an unauthorized user access a protected endpoint?
- Does the application expose insecure configuration?
- Can common security issues be detected automatically before release?
The good news is that Automation Test Engineers do not need to become penetration testers to start contributing to application security.
Many basic security checks can be integrated into the same automation and CI/CD workflows we already use every day.
What You’ll Learn
By the end of this article, you will know how to add basic automated security checks for:
- Secrets with Gitleaks
- Vulnerable dependencies with
npm audit - Insecure code patterns with Semgrep
- Security regression scenarios with Playwright
- Runtime security configuration with OWASP ZAP
The goal is not to build a complete AppSec program.
The goal is simpler:
Start small, automate repeatable security checks, and catch common problems earlier in the development lifecycle.
1. A Simple Security Testing Pipeline
A useful starting point looks like this:
Pull Request
|
+----------------+----------------+
| | |
v v v
Gitleaks npm audit Semgrep
Secrets Dependencies SAST
| | |
+----------------+----------------+
|
v
Playwright Tests
Functional + Security Checks
|
v
Merge
|
v
Deploy Staging
|
v
ZAP Baseline Scan
Each tool looks at a different part of the application.
Gitleaks detects credentials accidentally committed to source control.
npm audit checks third-party packages against known vulnerabilities.
Semgrep analyzes source code for potentially insecure patterns.
Playwright verifies security behavior that is part of the application’s expected contract.
OWASP ZAP checks the running application for common runtime and configuration issues.
No single tool catches everything.
That is why combining several small, focused checks is more useful than expecting one security scanner to solve every problem.
2. Secret Detection with Gitleaks
One of the easiest security checks to introduce is secret detection.
Developers and testers sometimes accidentally commit:
API keys
Database passwords
Access tokens
Private keys
Connection strings
For example:
const API_KEY = "sk_live_real_key_here";
Once a real credential is pushed to Git history, simply deleting it in the next commit may not be enough.
The secret may still exist in repository history and usually needs to be rotated.
Gitleaks helps detect this automatically.
GitHub Actions Example
name: Secret Detection
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
gitleaks:
name: Detect Hardcoded Secrets
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Run Gitleaks
uses: gitleaks/gitleaks-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0 allows the scanner to access the repository history instead of only the latest commit.
For most teams, detecting a real credential should be treated as a serious finding.
A pull request containing an exposed secret should normally not be merged until the issue has been investigated.
Practical tip: Avoid allowlisting an entire
tests/directory. Test code can leak real credentials too. If you need an exception, keep it as specific as possible and document why it is safe.
This is one of the highest-value security checks because it is simple, fast, and easy to automate.
3. Dependency Scanning with npm audit
Modern JavaScript applications depend on a large number of third-party packages.
Your application code may be secure, but a dependency can still contain a known vulnerability.
For Node.js projects, the simplest starting point is already included with npm:
npm audit
For CI, you may want to focus on production dependencies and define a meaningful failure threshold:
npm audit --omit=dev --audit-level=high
--omit=dev focuses the audit on runtime dependencies.
--audit-level=high changes the severity threshold that causes the command to fail.
It does not hide lower-severity findings from the report.
GitHub Actions Example
name: Dependency Security Scan
on:
pull_request:
branches: [main]
push:
branches: [main]
permissions:
contents: read
jobs:
dependency-scan:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: '24'
cache: npm
- name: Install dependencies
run: npm ci
- name: Audit production dependencies
run: npm audit --omit=dev --audit-level=high
This is intentionally simple.
You can later add:
- JSON reports
- Scheduled scans
- Dependabot or Renovate
- SBOM generation
- Dedicated SCA platforms
But none of those are required to start.
Avoid Automatically Fixing Everything
I would also avoid automatically running this in CI:
npm audit fix --force
A security scan should detect and report a dependency problem.
It should not silently introduce potentially breaking dependency upgrades into application code.
Review the vulnerability and the proposed upgrade before applying the fix.
4. Static Security Analysis with Semgrep
Dependency scanning looks at third-party packages.
SAST — Static Application Security Testing — looks at your own source code.
Consider this example:
const query = `SELECT * FROM users WHERE id = ${userId}`;
A functional test may execute the feature successfully and report:
PASS
From a functional perspective, the feature works.
But from a security perspective, building a SQL query directly from user-controlled input can be dangerous.
A static security scanner analyzes the source code without starting the application and can identify patterns like this.
Semgrep is a useful entry point because it can run directly inside CI.
Basic Semgrep Example
name: SAST Security Scan
on:
pull_request:
branches: [main]
permissions:
contents: read
jobs:
semgrep:
runs-on: ubuntu-latest
container:
image: semgrep/semgrep
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Run Semgrep
run: |
semgrep scan \
--config p/owasp-top-ten \
.
One important detail is that introducing SAST does not mean you should immediately fail every pull request.
The first scan of an existing project may produce findings that need investigation.
A better rollout is:
Step 1: Scan
Step 2: Review findings
Step 3: Tune noisy rules
Step 4: Establish a baseline
Step 5: Block only high-confidence findings
Once the team understands the results, you can choose to make findings fail the job:
semgrep scan \
--config p/owasp-top-ten \
--error \
.
The important principle is signal over noise.
If a security pipeline produces too many irrelevant failures, developers will eventually start ignoring it.
5. Security Regression Testing with Playwright
This is probably the most relevant area for Automation Test Engineers.
Security testing does not always require a specialized security scanner.
Some security requirements are simply application behavior.
And application behavior can be tested.
Testing Security Headers
Suppose your application is expected to return specific security headers.
You can verify them directly using Playwright:
import { test, expect } from '@playwright/test';
test('should return required security headers', async ({ request }) => {
const response = await request.get('/');
expect(response.status()).toBe(200);
const headers = response.headers();
expect(headers['x-content-type-options']).toBe('nosniff');
expect(headers['content-security-policy']).toBeTruthy();
});
This is a normal automated test.
If a deployment accidentally removes one of these required headers, the pipeline can detect the regression.
Important: Do not blindly copy every security header from an online checklist. Test the security requirements that actually apply to your application and environment.
For example, some HTTPS-specific behavior may not apply when tests run against a local HTTP environment.
Testing Protected Endpoints
Authorization is another area where normal automation can provide a lot of value.
Suppose an API endpoint requires authentication.
You can verify that anonymous access is rejected:
test('anonymous user cannot access admin API', async ({ request }) => {
const response = await request.get('/api/admin');
expect(response.status()).toBe(401);
});
You can then extend this into role-based authorization tests.
For example:
Anonymous user
-> Protected API
-> 401 Unauthorized
Normal user
-> Admin API
-> 403 Forbidden
Admin user
-> Admin API
-> Access allowed
User A
-> User B's private resource
-> Access denied
Expired token
-> Protected API
-> Access denied
Invalid token
-> Protected API
-> Access denied
These scenarios are both functional and security tests.
And unlike generic scanners, your automation suite understands how your application’s users, roles, and business rules are supposed to work.
Turning Security Bugs into Regression Tests
Automation Engineers already follow a useful rule:
If a bug was fixed and could happen again, add a regression test.
The same principle applies to security defects.
For example:
Bug:
Normal users could access /api/admin/settings.
Fix:
Authorization middleware was added.
Regression test:
Verify that a normal user receives 403.
Or:
Bug:
Session cookie was missing the Secure attribute.
Fix:
Cookie configuration was updated.
Regression test:
Verify the session cookie configuration.
Once a security problem has occurred once, automated regression coverage can help prevent it from quietly returning later.
This is one of the clearest ways Automation Test Engineers can contribute to security.
6. Runtime Security Scanning with OWASP ZAP
Static analysis and Playwright tests still cannot inspect everything happening in the running application.
That is where DAST — Dynamic Application Security Testing — can help.
OWASP ZAP is one of the best-known open-source tools in this area.
For teams just starting with security automation, I recommend beginning with the ZAP Baseline Scan.
Why Baseline Scan?
The Baseline Scan spiders the target and performs passive analysis.
It does not actively attack the application.
This makes it suitable for frequent automated scanning and much easier to introduce than a full active security scan.
GitHub Actions Example
name: ZAP Baseline Scan
on:
workflow_dispatch:
permissions:
contents: read
jobs:
zap:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Run ZAP Baseline
uses: zaproxy/action-baseline@v0.15.0
with:
target: ${{ vars.STAGING_URL }}
fail_action: false
I recommend starting with a staging environment and treating the results as informational.
A Baseline Scan can help identify issues such as:
- Missing security headers
- Cookie configuration problems
- Information disclosure
- Cache-related configuration
- Other passive security findings
But there is an important limitation.
A Baseline Scan is not the same as an active penetration test.
It does not actively send attack payloads to try to exploit SQL Injection, XSS, or similar vulnerabilities.
Those scenarios require active scanning or dedicated security testing.
Safety rule: Only scan environments that your team owns or that you have explicit authorization to test.
7. What Should Block a Pull Request?
The fastest way to make developers hate a security pipeline is simple:
Add five scanners and make every warning fail the build.
A better strategy is to introduce security gates gradually.
For example:
| Security Check | Suggested Starting Policy |
|---|---|
| Real leaked secret | Block |
| Failed Playwright security regression | Block |
| High/Critical dependency vulnerability | Review / Block based on agreed policy |
| Semgrep finding | Report first, then block selected rules |
| ZAP Baseline finding | Report / Warn initially |
There is an important distinction between:
A security finding exists.
and:
This release must be blocked.
Those are not always the same thing.
Severity is only one part of the decision.
Teams should also consider:
- Exploitability
- Whether the vulnerable code is reachable
- Whether the issue affects production
- Whether a fix is available
- Existing compensating controls
- Business impact
The important part is to define the policy explicitly instead of deciding differently every time a scanner reports something.
8. Keep the Security Pipeline Secure
There is an interesting problem with security automation:
The security pipeline itself can become part of your attack surface.
A simple starting point is limiting GitHub Actions permissions:
permissions:
contents: read
Only add write permissions when a job actually needs them.
For example, a scanner that only reads source code probably does not need permission to modify repository contents.
You should also treat third-party GitHub Actions like dependencies.
Review:
- Who maintains the Action?
- What permissions does it require?
- Does it need access to repository secrets?
- Is the version pinned?
- Is the project actively maintained?
For readability, the examples in this article use release tags such as:
actions/checkout@v7
For production security-sensitive workflows, consider pinning third-party Actions to verified full commit SHAs.
A security scanner with unnecessary write access can create a new security risk instead of reducing one.
9. Where OWASP ASVS Fits
If your team wants to formalize application security requirements, OWASP ASVS — Application Security Verification Standard — is a useful reference.
However, there is an important distinction:
Running a scanner does not automatically prove that an ASVS requirement has been fully verified.
For example:
Semgrep
-> may detect an unsafe SQL pattern
Playwright
-> may verify an authorization scenario
ZAP
-> may detect missing security headers
These automated checks can support parts of your security verification.
But none of them individually prove that an entire ASVS chapter is covered.
A better way to think about it is:
OWASP ASVS
|
v
Security Requirements
|
+--> Automated Tests
|
+--> Security Scanners
|
+--> Code Review
|
+--> Manual Verification
|
+--> Penetration Testing
Use ASVS as a requirements and verification framework.
Use automation as one source of evidence.
10. What This Approach Does Not Replace
It is equally important to understand what automated security testing cannot do.
This basic pipeline does not replace:
- Manual penetration testing
- Threat modeling
- Security-focused code review
- Deep authentication testing
- Complex authorization testing
- Business logic security testing
Automated tools are especially weak at questions such as:
Should this user be allowed to approve this transaction?
Can a user manipulate several valid steps to bypass a business rule?
Can User A access User B's data through an unexpected workflow?
Can two individually valid operations be combined into an unsafe state?
These require context and human reasoning.
The goal of automation is not to eliminate security specialists.
It is to automatically detect repeatable problems so people can spend more time on the difficult ones.
11. Where to Go Next
Once the basic pipeline is working reliably, you can expand it.
Container Scanning
Tools such as Trivy can scan container images for vulnerable operating-system packages and application dependencies.
Infrastructure-as-Code Scanning
Tools such as Checkov can analyze:
Terraform
Kubernetes
CloudFormation
Dockerfiles
for insecure infrastructure configuration.
SBOM Generation
A Software Bill of Materials can improve visibility into the components included in your application.
Advanced DAST
ZAP Active Scan or API Scan can perform deeper runtime security testing.
These scans require more careful configuration because they actively interact with the target application.
Authenticated Security Testing
Authenticated DAST can significantly increase coverage, but authentication flows involving OAuth, OIDC, MFA, or Conditional Access can make the setup much more complex.
That topic deserves its own article.
Custom Security Rules
Once the team understands its common security mistakes, custom Semgrep rules can enforce organization-specific secure coding patterns.
The key is not to implement all of these immediately.
Build trust in the basic pipeline first.
Then add more advanced security automation when there is a clear reason to do so.
12. Conclusion
Security testing does not have to begin with advanced penetration testing.
Automation Test Engineers already have many of the skills needed to introduce basic security checks:
- Writing automated tests
- Testing APIs
- Designing negative scenarios
- Building CI/CD pipelines
- Analyzing failures
- Maintaining regression suites
- Creating quality gates
A practical starting point is:
Gitleaks
|
+-- Secret Detection
npm audit
|
+-- Dependency Security
Semgrep
|
+-- Static Security Analysis
Playwright
|
+-- Security Regression Tests
OWASP ZAP
|
+-- Runtime Security Checks
You do not need to implement everything at once.
Start with one or two high-value checks.
Keep the signal useful.
Turn real security defects into regression tests.
Then gradually expand the pipeline as the team’s security maturity grows.
A green pipeline should not only tell you:
The application works.
Over time, it should also give the team confidence that:
Common security mistakes have not quietly returned.