<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-to-catch-security-vulnerabilities-in-code-before-they-reach-your-pull-requests-bfxw4rcsv" -->

---
title: How to Catch Security Vulnerabilities in Code Before...
description: A step-by-step guide walks through shifting security scanning left using Git pre-commit hooks. It covers installing the DevSkim CLI security linter, wiring it...
canonical: https://daily.dev/posts/how-to-catch-security-vulnerabilities-in-code-before-they-reach-your-pull-requests-bfxw4rcsv
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How to Catch Security Vulnerabilities in Code Before They Reach Your Pull Requests | daily.dev
og:description: A step-by-step guide walks through shifting security scanning left using Git pre-commit hooks. It covers installing the DevSkim CLI security linter, wiring it...
og:url: https://daily.dev/posts/how-to-catch-security-vulnerabilities-in-code-before-they-reach-your-pull-requests-bfxw4rcsv
og:image: https://api.daily.dev/og/posts/BfXW4rCSV.png
og:image:alt: How to Catch Security Vulnerabilities in Code Before They Reach Your Pull Requests
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Catch Security Vulnerabilities in Code Before They Reach Your Pull Requests

**[freeCodeCamp](https://daily.dev/sources/freecodecamp)** · 9 min read · 4 upvotes · 0 comments

## Summary

A step-by-step guide walks through shifting security scanning left using Git pre-commit hooks. It covers installing the DevSkim CLI security linter, wiring it into pre-commit to lint staged files, pairing it with Gitleaks for dedicated secret scanning, verifying the setup with deliberate failures (a weak MD5 hash and a hardcoded API key), and enforcing the same checks in a GitHub Actions CI workflow. Practical advice covers keeping hooks fast by scanning only staged files, handling false positives with narrow suppressions rather than broad exclusions, and rolling out gradually starting with high-confidence findings.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.freecodecamp.org/news/catch-security-vulnerabilities-code-pull-requests>

## Questions this post answers

### What's the difference between DevSkim and Gitleaks for security scanning?

DevSkim is a security linter created by Microsoft that flags insecure coding patterns like weak cryptography, insecure deserialization, weak TLS validation, and command injection risks, while Gitleaks is a dedicated secret scanner using entropy and pattern checks tuned for credentials. DevSkim bundles only generic regex-based credential rules aimed at long, token-like values, so teams typically pair it with Gitleaks, detect-secrets, or TruffleHog for reliable secret detection.

_Comparing security linters and secret scanners before adopting one is easier with daily.dev._

### How do I run DevSkim on multiple staged files in a pre-commit hook without it breaking?

DevSkim's CLI only accepts a single source path after the -I flag, but pre-commit passes every staged filename to the command, so calling devskim analyze directly fails once a commit touches more than one file. The fix is a small Python wrapper script that loops over each filename in sys.argv and invokes devskim analyze -I on it individually, tracking the combined exit code.

_Wiring linters into pre-commit hooks correctly is the kind of workflow fix daily.dev surfaces for developers._

### How do I stop Gitleaks from missing secrets committed in earlier Git history during CI scans?

Set fetch-depth: 0 on the actions/checkout step in the GitHub Actions workflow, which gives Gitleaks the full repository history to scan rather than just the latest commit. Without full history, Gitleaks can only check the tip of the branch and would miss secrets buried in earlier commits.

_Getting CI secret scanning configured right matters for anyone hardening a pipeline, something daily.dev readers track closely._

## Similar posts on daily.dev

- [Security Checklist for GitHub Actions](https://daily.dev/posts/security-checklist-for-github-actions-up1jad7nx) · Aikido Security · 5 upvotes · 0 comments
- [The vulnerabilities nobody sees in your repository, and how to catch them before they merge](https://daily.dev/posts/the-vulnerabilities-nobody-sees-in-your-repository-and-how-to-catch-them-before-they-merge-qmufkovsn) · Medium · 1 upvotes · 0 comments
- [How to Fix a Leaked API Key: A Developer’s Guide to Git Security](https://daily.dev/posts/how-to-fix-a-leaked-api-key-a-developer-s-guide-to-git-security-43yrnksw9) · freeCodeCamp · 5 upvotes · 1 comments
- [Shift Left Security: 4 Automated Security Gates in GitHub Actions](https://daily.dev/posts/shift-left-security-4-automated-security-gates-in-github-actions-fvzdpsxyd) · DevOps.com · 1 upvotes · 0 comments
- [GenAI-based development platform](https://daily.dev/posts/genai-based-development-platform-amtrdhklf) · Microservices.io · 0 upvotes · 0 comments

---

Tags: [#security](https://daily.dev/tags/security), [#cicd](https://daily.dev/tags/cicd)

[View this post on daily.dev](https://daily.dev/posts/how-to-catch-security-vulnerabilities-in-code-before-they-reach-your-pull-requests-bfxw4rcsv)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How to Catch Security Vulnerabilities in Code Before They Reach Your Pull Requests","url":"https://daily.dev/posts/how-to-catch-security-vulnerabilities-in-code-before-they-reach-your-pull-requests-bfxw4rcsv","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-to-catch-security-vulnerabilities-in-code-before-they-reach-your-pull-requests-bfxw4rcsv"},"datePublished":"2026-09-15T01:03:04.870Z","dateModified":"2026-09-15T01:03:36.537Z","description":"A step-by-step guide walks through shifting security scanning left using Git pre-commit hooks. It covers installing the DevSkim CLI security linter, wiring it...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/f78e3050c6d60e648b110e41b7c652a6?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/f78e3050c6d60e648b110e41b7c652a6?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"freeCodeCamp","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"freeCodeCamp","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1628412854/logos/freecodecamp","url":"https://daily.dev/sources/freecodecamp"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-to-catch-security-vulnerabilities-in-code-before-they-reach-your-pull-requests-bfxw4rcsv","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":4},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"security,cicd","timeRequired":"PT9M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"freeCodeCamp","item":"https://daily.dev/sources/freecodecamp"},{"@type":"ListItem","position":3,"name":"How to Catch Security Vulnerabilities in Code Before They Reach Your Pull Requests"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-to-catch-security-vulnerabilities-in-code-before-they-reach-your-pull-requests-bfxw4rcsv#faq","mainEntity":[{"@type":"Question","name":"What's the difference between DevSkim and Gitleaks for security scanning?","acceptedAnswer":{"@type":"Answer","text":"DevSkim is a security linter created by Microsoft that flags insecure coding patterns like weak cryptography, insecure deserialization, weak TLS validation, and command injection risks, while Gitleaks is a dedicated secret scanner using entropy and pattern checks tuned for credentials. DevSkim bundles only generic regex-based credential rules aimed at long, token-like values, so teams typically pair it with Gitleaks, detect-secrets, or TruffleHog for reliable secret detection. Comparing security linters and secret scanners before adopting one is easier with daily.dev."}},{"@type":"Question","name":"How do I run DevSkim on multiple staged files in a pre-commit hook without it breaking?","acceptedAnswer":{"@type":"Answer","text":"DevSkim's CLI only accepts a single source path after the -I flag, but pre-commit passes every staged filename to the command, so calling devskim analyze directly fails once a commit touches more than one file. The fix is a small Python wrapper script that loops over each filename in sys.argv and invokes devskim analyze -I on it individually, tracking the combined exit code. Wiring linters into pre-commit hooks correctly is the kind of workflow fix daily.dev surfaces for developers."}},{"@type":"Question","name":"How do I stop Gitleaks from missing secrets committed in earlier Git history during CI scans?","acceptedAnswer":{"@type":"Answer","text":"Set fetch-depth: 0 on the actions/checkout step in the GitHub Actions workflow, which gives Gitleaks the full repository history to scan rather than just the latest commit. Without full history, Gitleaks can only check the tip of the branch and would miss secrets buried in earlier commits. Getting CI secret scanning configured right matters for anyone hardening a pipeline, something daily.dev readers track closely."}}]}
```

