<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Matteo Vitali</title>
    <description>The latest articles on DEV Community by Matteo Vitali (@trottomv).</description>
    <link>https://dev.to/trottomv</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2734053%2F003bdc72-a559-4656-a88d-6acd76a42996.jpg</url>
      <title>DEV Community: Matteo Vitali</title>
      <link>https://dev.to/trottomv</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/trottomv"/>
    <language>en</language>
    <item>
      <title>From SBOM to Vulnerability Management: How Argus SBOM Guard was born</title>
      <dc:creator>Matteo Vitali</dc:creator>
      <pubDate>Fri, 13 Nov 2026 09:41:00 +0000</pubDate>
      <link>https://dev.to/trottomv/from-sbom-to-vulnerability-management-why-i-built-argus-sbom-guard-3oic</link>
      <guid>https://dev.to/trottomv/from-sbom-to-vulnerability-management-why-i-built-argus-sbom-guard-3oic</guid>
      <description>&lt;p&gt;&lt;em&gt;Did we really need yet another open-source security tool? &lt;br&gt;
A journey from software supply chain visibility to vulnerability management.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Let's start with a simple question.&lt;/p&gt;

&lt;p&gt;Imagine you are responsible for the security of an organization running several applications, microservices, and third-party software components.&lt;/p&gt;

&lt;p&gt;A new critical vulnerability is disclosed. How quickly can you determine whether your systems are affected?&lt;/p&gt;

&lt;p&gt;Do you know which applications include the vulnerable dependency? Which versions are affected? Can you track the issue until it is fixed?&lt;/p&gt;

&lt;p&gt;This is one of the challenges of modern vulnerability management.&lt;/p&gt;

&lt;p&gt;Software supply chains have become increasingly complex. Applications depend on hundreds of open-source libraries and third-party components, often through multiple layers of transitive dependencies.&lt;/p&gt;

&lt;p&gt;Knowing what is running in your infrastructure is no longer enough. You also need to understand what your software is made of.&lt;/p&gt;

&lt;p&gt;This is where Software Bills of Materials (SBOMs) come into play.&lt;/p&gt;

&lt;p&gt;But generating an SBOM is only the beginning.&lt;/p&gt;

&lt;p&gt;In this article, I'll explain the relationship between Risk Management, Vulnerability Management, and SBOMs, and introduce &lt;strong&gt;Argus SBOM Guard&lt;/strong&gt;, an open-source project I started to address some of the practical challenges I encountered in this area.&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Risk Management &amp;amp; Vulnerability Management
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe8wrasnfa5b7f47kxcit.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe8wrasnfa5b7f47kxcit.png" alt="rm vm" width="800" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before talking about tools and technologies, I think it is important to clarify one fundamental concept: identifying a vulnerability is not the same as managing a risk.&lt;/p&gt;

&lt;p&gt;Risk Management is about understanding and evaluating potential events that could negatively affect an organization.&lt;/p&gt;

&lt;p&gt;A simplified way to express this concept is:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Risk = Probability × Impact&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The probability of an event occurring and the potential damage it could cause contribute to determining its risk level.&lt;/p&gt;

&lt;p&gt;Vulnerability Management is one of the activities that supports this broader process.&lt;/p&gt;

&lt;p&gt;Its purpose is to identify security weaknesses, evaluate their potential impact, prioritize remediation, and monitor their evolution over time.&lt;/p&gt;

&lt;p&gt;However, a vulnerability scanner alone cannot make all these decisions.&lt;/p&gt;

&lt;p&gt;A vulnerability with a high CVSS score is not necessarily the most urgent issue in every environment. Context matters: exposure, exploitability, business criticality, and the role of the affected component all contribute to the final assessment.&lt;/p&gt;

&lt;p&gt;The goal is therefore not simply to collect CVEs, but to turn vulnerability information into actionable risk management decisions.&lt;/p&gt;
&lt;h2&gt;
  
  
  2. The first challenge: knowing what you ship
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqtozd0utcga4a3yn17u7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqtozd0utcga4a3yn17u7.png" alt="sbom supply chain" width="800" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Consider a typical software environment.&lt;/p&gt;

&lt;p&gt;You might have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Applications developed internally.&lt;/li&gt;
&lt;li&gt;Third-party services and SaaS platforms.&lt;/li&gt;
&lt;li&gt;Container images and microservices.&lt;/li&gt;
&lt;li&gt;Open-source libraries and frameworks.&lt;/li&gt;
&lt;li&gt;Dependencies managed by different development teams.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now imagine trying to understand which components are affected by a newly disclosed vulnerability.&lt;/p&gt;

&lt;p&gt;Without a reliable software inventory, this can quickly become a difficult and mostly manual activity.&lt;/p&gt;

&lt;p&gt;A Software Bill of Materials (SBOM) helps solve this problem.&lt;/p&gt;

&lt;p&gt;An SBOM is a machine-readable inventory of the components, libraries, and modules included in a software product.&lt;/p&gt;

&lt;p&gt;Think of it as an ingredient list for software.&lt;/p&gt;

&lt;p&gt;Depending on the format, an SBOM can contain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Component name and version.&lt;/li&gt;
&lt;li&gt;Supplier and author information.&lt;/li&gt;
&lt;li&gt;Unique identifiers such as PURL and CPE.&lt;/li&gt;
&lt;li&gt;Cryptographic hashes.&lt;/li&gt;
&lt;li&gt;Direct and transitive dependencies.&lt;/li&gt;
&lt;li&gt;Licensing information.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two widely adopted SBOM standards are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SPDX&lt;/strong&gt;, maintained by the Linux Foundation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CycloneDX&lt;/strong&gt;, maintained by OWASP.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;SBOM adoption is also becoming increasingly relevant from a regulatory perspective. The European Cyber Resilience Act (CRA), for example, introduces cybersecurity requirements for products with digital elements, including software component documentation and vulnerability handling.&lt;/p&gt;

&lt;p&gt;But beyond compliance, the real benefit is visibility.&lt;/p&gt;

&lt;p&gt;An SBOM allows us to understand the composition of our software and provides a starting point for identifying potentially vulnerable components.&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Generating an SBOM
&lt;/h2&gt;

&lt;p&gt;Several open-source tools can generate SBOMs.&lt;/p&gt;

&lt;p&gt;One of them is &lt;a href="https://github.com/anchore/syft" rel="noopener noreferrer"&gt;Syft&lt;/a&gt;, which can inspect container images and filesystems to identify software packages.&lt;/p&gt;

&lt;p&gt;Let's assume we have a Docker image that we want to analyze.&lt;/p&gt;

&lt;p&gt;First, build and publish the image, then generate an SBOM from the resulting artifact:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ docker build --pull --tag registry.example.com/myproject/myapp:1.0 .

$ docker push registry.example.com/myproject/myapp:1.0

$ syft registry.example.com/myproject/myapp:1.0 \
    --output spdx-json=./sbom_spdx.json \
    --output cyclonedx-json=./sbom_cdx.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We now have two machine-readable inventories describing the software components included in our application.&lt;/p&gt;

&lt;p&gt;For example, a CycloneDX document contains component information such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;cat&lt;/span&gt; &lt;span class="err"&gt;./&lt;/span&gt;&lt;span class="n"&gt;sbom_cdx&lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"$schema"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"http://cyclonedx.org/schema/bom-1.7.schema.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"bomFormat"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"CycloneDX"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"specVersion"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"1.7"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"metadata"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nl"&gt;"timestamp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2026-09-10T10:06:17+02:00"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="err"&gt;…&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"components"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;       
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nl"&gt;"bom-ref"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"pkg:pypi/fastapi@0.141.1?package-id=1a4c…"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"library"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nl"&gt;"author"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Sebastian Ramirez &amp;lt;tiangolo@gmail.com&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"fastapi"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0.141.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nl"&gt;"licenses"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"license"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"MIT"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nl"&gt;"cpe"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"cpe:2.3:a:python-fastapi:python-fastapi:0.141.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nl"&gt;"purl"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"pkg:pypi/fastapi@0.141.1"&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="err"&gt;…&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a simplified example, but it illustrates the kind of information that can be extracted from an SBOM.&lt;/p&gt;

&lt;p&gt;At this point, we know what our application contains.&lt;/p&gt;

&lt;p&gt;But how do we know whether those components have known vulnerabilities?&lt;/p&gt;

&lt;h2&gt;
  
  
  4. From SBOM to vulnerability scanning
&lt;/h2&gt;

&lt;p&gt;Once we have an SBOM, we can use vulnerability analysis tools to correlate its components with known security issues.&lt;/p&gt;

&lt;p&gt;For example, &lt;a href="https://github.com/anchore/grype" rel="noopener noreferrer"&gt;Grype&lt;/a&gt; can analyze an SBOM and identify known vulnerabilities affecting its dependencies.&lt;/p&gt;

&lt;p&gt;Using the CycloneDX document generated earlier:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ grype sbom:./sbom_cdx.json
NAME          INSTALLED     FIXED IN      TYPE       VULNERABILITY         SEVERITY    EPSS          RISK
…
virtualenv     21.7.0       21.7.13      python     GHSA-p58f-9548-mpm2    High        0.2% &lt;span class="o"&gt;(&lt;/span&gt;4th&lt;span class="o"&gt;)&lt;/span&gt;    0.1
libcrypto3     3.5.7-r1                  apk        CVE-2026-75805         Medium      0.2% &lt;span class="o"&gt;(&lt;/span&gt;11th&lt;span class="o"&gt;)&lt;/span&gt;   0.1
libssl3        3.5.7-r1                  apk        CVE-2026-75805         Medium      0.2% &lt;span class="o"&gt;(&lt;/span&gt;11th&lt;span class="o"&gt;)&lt;/span&gt;   0.1
openssl        3.5.7-r1                  apk        CVE-2026-75805         Medium      0.2% &lt;span class="o"&gt;(&lt;/span&gt;11th&lt;span class="o"&gt;)&lt;/span&gt;   0.1
…

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output includes information such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Component name.&lt;/li&gt;
&lt;li&gt;Installed version.&lt;/li&gt;
&lt;li&gt;Fixed version, when available.&lt;/li&gt;
&lt;li&gt;Vulnerability identifier.&lt;/li&gt;
&lt;li&gt;Severity.&lt;/li&gt;
&lt;li&gt;EPSS information.&lt;/li&gt;
&lt;li&gt;Risk-related information.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This provides a much clearer picture of our application's security exposure.&lt;/p&gt;

&lt;p&gt;However, we have introduced another problem. Running a vulnerability scan once is not enough.&lt;/p&gt;

&lt;p&gt;New vulnerabilities are disclosed every day. A component that was considered secure yesterday might be affected by a newly published CVE tomorrow.&lt;/p&gt;

&lt;p&gt;Even if the application has not changed, its known security exposure has.&lt;/p&gt;

&lt;p&gt;This is why SBOM management should be part of a continuous Vulnerability Management process.&lt;/p&gt;

&lt;p&gt;We need a way to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Collect SBOMs from different applications and services.&lt;/li&gt;
&lt;li&gt;Maintain an inventory and version history.&lt;/li&gt;
&lt;li&gt;Continuously analyze dependencies against vulnerability information.&lt;/li&gt;
&lt;li&gt;Track findings and their remediation status.&lt;/li&gt;
&lt;li&gt;Support risk assessment and prioritization.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And this brings us to the next question.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Make or Buy? (Or use an Open Source tool on premise?)
&lt;/h2&gt;

&lt;p&gt;When I started thinking about this problem, I looked at the existing ecosystem.&lt;/p&gt;

&lt;p&gt;There are already excellent tools for generating SBOMs and identifying vulnerabilities: Syft, Grype, Trivy, OSV, and many others.&lt;/p&gt;

&lt;p&gt;There are also platforms that provide software composition analysis and vulnerability management capabilities.&lt;/p&gt;

&lt;p&gt;So, why build another tool?&lt;/p&gt;

&lt;p&gt;I wasn't interested in reinventing an SBOM generator.&lt;/p&gt;

&lt;p&gt;I didn't want to build yet another CVE database or duplicate the work already done by existing vulnerability scanners.&lt;/p&gt;

&lt;p&gt;What I was looking for was something slightly different:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What I needed&lt;/th&gt;
&lt;th&gt;What I didn't want&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Centralized SBOM ingestion&lt;/td&gt;
&lt;td&gt;Another SBOM generator&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dependency and SBOM history&lt;/td&gt;
&lt;td&gt;Another CVE database&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Vulnerability correlation&lt;/td&gt;
&lt;td&gt;A duplication of Grype, Trivy, or OSV&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A simple management interface&lt;/td&gt;
&lt;td&gt;A monolithic platform&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API and CI/CD integration&lt;/td&gt;
&lt;td&gt;Manual workflows&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Open source and self-hosted&lt;/td&gt;
&lt;td&gt;Black boxes and vendor lock-in&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;I wanted a lightweight platform that could connect existing tools and provide a centralized place to manage their results.&lt;/p&gt;

&lt;p&gt;Something that could be deployed on-premises, integrated into existing workflows, and used without introducing an unnecessarily complex infrastructure.&lt;/p&gt;

&lt;p&gt;That's how &lt;strong&gt;Argus SBOM Guard&lt;/strong&gt; started.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Meet Argus SBOM Guard
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx75bzuj8qmb8y2fehsvs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx75bzuj8qmb8y2fehsvs.png" alt="argus dashboard" width="800" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Argus SBOM Guard is an open-source platform for centralized SBOM and vulnerability management.&lt;/p&gt;

&lt;p&gt;It is designed to be self-hosted, either on-premises or in your own infrastructure.&lt;/p&gt;

&lt;p&gt;Its main goal is simple:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Turn SBOMs into actionable vulnerability management information.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The platform provides several capabilities:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SBOM ingestion:&lt;/strong&gt; upload and store CycloneDX and SPDX documents.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vulnerability scanning:&lt;/strong&gt; automatic analysis using Grype and the OSV API.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vulnerability tracking:&lt;/strong&gt; CVE status management, including open, fixed, and won't-fix findings.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Supply chain visibility:&lt;/strong&gt; organize projects, services, dependencies, and software versions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Historical tracking:&lt;/strong&gt; maintain SBOM and vulnerability history.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dashboards:&lt;/strong&gt; visualize vulnerability trends and project-level metrics.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integrations:&lt;/strong&gt; REST API and gRPC with API key authentication.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Alerting:&lt;/strong&gt; notifications through Slack, Discord, and email.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Who is it for?
&lt;/h3&gt;

&lt;p&gt;I see several potential use cases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Platform and SRE teams tracking dependencies across microservices.&lt;/li&gt;
&lt;li&gt;Security engineers monitoring vulnerability exposure over time.&lt;/li&gt;
&lt;li&gt;DevSecOps teams integrating SBOM management into CI/CD pipelines.&lt;/li&gt;
&lt;li&gt;Open-source maintainers managing software dependencies.&lt;/li&gt;
&lt;li&gt;Compliance teams requiring SBOM history and audit trails.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The idea is not to replace existing security tools, but to provide a centralized layer for managing SBOMs and their associated vulnerability information.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Under the hood: How does It work?
&lt;/h2&gt;

&lt;p&gt;One of the design principles behind Argus is to reuse existing tools rather than reimplement their functionality.&lt;/p&gt;

&lt;p&gt;The architecture is based on a few relatively independent components.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Technology&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Reverse proxy + WAF&lt;/td&gt;
&lt;td&gt;Caddy + OWASP Coraza&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Backend&lt;/td&gt;
&lt;td&gt;FastAPI + SQLAlchemy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Background processing&lt;/td&gt;
&lt;td&gt;RabbitMQ + Celery&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Database&lt;/td&gt;
&lt;td&gt;PostgreSQL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Frontend&lt;/td&gt;
&lt;td&gt;Jinja2 + HTMX + Alpine.js + Tailwind CSS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Vulnerability scanning&lt;/td&gt;
&lt;td&gt;Grype + OSV API&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Observability&lt;/td&gt;
&lt;td&gt;OpenTelemetry&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deployment&lt;/td&gt;
&lt;td&gt;Docker Compose&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The backend exposes REST and gRPC interfaces, while asynchronous tasks are handled by Celery workers.&lt;/p&gt;

&lt;p&gt;This is particularly useful for vulnerability scanning, which should not block the SBOM upload process.&lt;/p&gt;

&lt;h3&gt;
  
  
  The SBOM ingestion workflow
&lt;/h3&gt;

&lt;p&gt;When a client uploads an SBOM through the API, the following operations take place:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The document is parsed according to its format (CycloneDX or SPDX).&lt;/li&gt;
&lt;li&gt;Its components and dependencies are stored in PostgreSQL.&lt;/li&gt;
&lt;li&gt;The upload request returns successfully.&lt;/li&gt;
&lt;li&gt;A background scanning task is dispatched through RabbitMQ.&lt;/li&gt;
&lt;li&gt;A Celery worker performs the vulnerability analysis.&lt;/li&gt;
&lt;li&gt;Findings are stored and reconciled against previous vulnerability information.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The important detail is that SBOM ingestion and vulnerability analysis are decoupled.&lt;/p&gt;

&lt;p&gt;This makes it possible to process potentially expensive scanning operations asynchronously while keeping the API responsive.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fp4e6oanc3w4ctb6x3c8b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fp4e6oanc3w4ctb6x3c8b.png" alt="argus request flow" width="800" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Vulnerability tracking
&lt;/h3&gt;

&lt;p&gt;Argus does not simply store the output of a vulnerability scan.&lt;/p&gt;

&lt;p&gt;It also maintains the relationship between SBOM versions, dependencies, and vulnerability findings.&lt;/p&gt;

&lt;p&gt;This allows the platform to track how the security posture of a project evolves over time.&lt;/p&gt;

&lt;p&gt;For example, when a dependency is upgraded and a new SBOM is uploaded, the platform can reconcile the new findings against previous results.&lt;/p&gt;

&lt;p&gt;This provides visibility into vulnerabilities that have been resolved, those that remain open, and those that have been explicitly marked as won't-fix.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Integrating Argus into your CI/CD pipeline
&lt;/h2&gt;

&lt;p&gt;A vulnerability management platform becomes much more useful when it is integrated into the software delivery process.&lt;/p&gt;

&lt;p&gt;Argus exposes an API that can be used to automate SBOM ingestion.&lt;/p&gt;

&lt;p&gt;For example, after generating a CycloneDX document, we can upload it with a simple HTTP request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ curl --fail -X POST &lt;span class="s2"&gt;"${ARGUS_URL}/api/v1/sboms/upload"&lt;/span&gt; \
    --header &lt;span class="s2"&gt;"Authorization: Bearer ${ARGUS_API_KEY}"&lt;/span&gt; \
    --form &lt;span class="s2"&gt;"project_slug=my-project"&lt;/span&gt; \
    --form &lt;span class="s2"&gt;"service_name=my-app"&lt;/span&gt; \
    --form &lt;span class="s2"&gt;"version=1.2.3"&lt;/span&gt; \
    --form &lt;span class="s2"&gt;"file=@sbom_cdx.json"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes it possible to integrate SBOM publication into GitHub Actions, GitLab CI, Jenkins, or other automation platforms.&lt;/p&gt;

&lt;p&gt;Every software release can generate and publish its own SBOM.&lt;/p&gt;

&lt;p&gt;Argus can then process the document and perform vulnerability analysis.&lt;/p&gt;

&lt;p&gt;Periodic reassessment provides an additional layer of protection: newly disclosed vulnerabilities can be identified against previously uploaded SBOMs, even when the software itself has not changed.&lt;/p&gt;

&lt;p&gt;The result is a workflow that connects software development with continuous vulnerability monitoring.&lt;/p&gt;

&lt;p&gt;For more details, see the &lt;a href="https://trottomv.github.io/argus-sbomguard/latest/guide/ci/" rel="noopener noreferrer"&gt;CI/CD integration documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. A small side project that became a real tool
&lt;/h2&gt;

&lt;p&gt;Argus SBOM Guard started as a side project.&lt;/p&gt;

&lt;p&gt;There was no business strategy, no product roadmap driven by market research, and no intention to create yet another commercial security platform.&lt;/p&gt;

&lt;p&gt;It started with curiosity and the desire to build something useful.&lt;/p&gt;

&lt;p&gt;As a developer, I enjoy exploring technologies, experimenting with architectures, and getting my hands dirty.&lt;/p&gt;

&lt;p&gt;The project was also an opportunity to explore how AI-assisted development could support the implementation process.&lt;/p&gt;

&lt;p&gt;The first stable version came together in a little over a month, with a relatively small investment in AI tooling.&lt;/p&gt;

&lt;p&gt;The result is an open-source project that can be self-hosted without requiring an entire datacenter or a complex enterprise infrastructure.&lt;/p&gt;

&lt;p&gt;And perhaps this is the most important aspect: the project is not intended to be a black box.&lt;/p&gt;

&lt;p&gt;The source code is available, the architecture is documented, and contributions are welcome.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final thoughts: Did we really need another Open Source tool?
&lt;/h2&gt;

&lt;p&gt;Maybe we did. Maybe we didn't.&lt;/p&gt;

&lt;p&gt;There are already excellent tools for generating SBOMs and identifying vulnerabilities.&lt;/p&gt;

&lt;p&gt;But I believe there is still value in connecting these capabilities through a simple, centralized, and self-hostable vulnerability management workflow.&lt;/p&gt;

&lt;p&gt;The objective of Argus SBOM Guard is not to replace existing security solutions.&lt;/p&gt;

&lt;p&gt;It is to make the information they produce easier to organize, understand, monitor, and act upon.&lt;/p&gt;

&lt;p&gt;Because generating an SBOM is not the end of the process.&lt;/p&gt;

&lt;p&gt;It is the beginning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Don't just generate SBOMs. Make them useful.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Try Argus SBOM Guard
&lt;/h3&gt;

&lt;p&gt;The project is open source, and I'd be happy to receive feedback, suggestions, and contributions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GitHub: &lt;a href="https://github.com/trottomv/argus-sbomguard/" rel="noopener noreferrer"&gt;https://github.com/trottomv/argus-sbomguard/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Documentation: &lt;a href="https://trottomv.github.io/argus-sbomguard/latest/" rel="noopener noreferrer"&gt;https://trottomv.github.io/argus-sbomguard/latest/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Contributors, early adopters and beta testers are welcome.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you work with SBOMs, software supply chain security, or vulnerability management, I'd love to hear your thoughts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Did we really need another open-source tool? Let me know what you think!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>devsecops</category>
      <category>security</category>
      <category>sboms</category>
      <category>cybersecurity</category>
    </item>
    <item>
      <title>🔐Enforcing image provenance in Kubernetes using Cosign + Sigstore + Kyverno</title>
      <dc:creator>Matteo Vitali</dc:creator>
      <pubDate>Mon, 04 May 2026 08:22:45 +0000</pubDate>
      <link>https://dev.to/trottomv/enforcing-image-provenance-in-kubernetes-using-cosign-sigstore-kyverno-kna</link>
      <guid>https://dev.to/trottomv/enforcing-image-provenance-in-kubernetes-using-cosign-sigstore-kyverno-kna</guid>
      <description>&lt;p&gt;What if your Kubernetes cluster simply refused to run unsigned images?&lt;/p&gt;

&lt;p&gt;I spent some time experimenting with enforcing image provenance in a small Kubernetes setup using MicroK8s.&lt;/p&gt;

&lt;p&gt;The idea was simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Only container images with valid cryptographic signatures are allowed to run in the cluster.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For this I used:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GitLab CI/CD (build + signing pipeline)&lt;/li&gt;
&lt;li&gt;Cosign / Sigstore (image signing)&lt;/li&gt;
&lt;li&gt;Kyverno (admission control)&lt;/li&gt;
&lt;li&gt;MicroK8s (local cluster)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/trottomv/microk8s-cosign-kyverno" rel="noopener noreferrer"&gt;https://github.com/trottomv/microk8s-cosign-kyverno&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Why this matters
&lt;/h2&gt;

&lt;p&gt;Most Kubernetes setups still rely on mutable image tags like &lt;code&gt;latest&lt;/code&gt;, which introduces supply chain risks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No guarantee of image origin&lt;/li&gt;
&lt;li&gt;No binding between CI pipeline and deployed artifact&lt;/li&gt;
&lt;li&gt;Risk of registry or tag mutation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the trust gap is basically:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;build time → registry → runtime&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──────────────────────────────┐
│        GitLab CI/CD          │
│                              │
│  • Build container image     │
│  • Push to OCI registry      │
│  • Sign image (Cosign)       │
│  • Publish signature         │
└──────────────┬───────────────┘
               │
               ▼
┌──────────────────────────────┐
│        OCI Registry          │
│   (image + signature)        │
└──────────────┬───────────────┘
               │
               ▼
┌──────────────────────────────┐
│   Kubernetes (MicroK8s)      │
│                              │
│  Kyverno Admission Controller│
│  • verify Cosign signature   │
│  • resolve image digest      │
│  • enforce policy decision   │
│                              │
│  → allow / reject Pod        │
└──────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  CI/CD: GitLab as trust origin
&lt;/h2&gt;

&lt;p&gt;The image is built and signed inside GitLab CI/CD.&lt;/p&gt;

&lt;p&gt;Example pipeline:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;stages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;build&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;sign&lt;/span&gt;

&lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;build&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;docker build -t $IMAGE:$TAG .&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;docker push $IMAGE:$TAG&lt;/span&gt;

&lt;span class="na"&gt;sign&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sign&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;cosign sign --key $COSIGN_KEY $IMAGE:$TAG&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rule is simple:&lt;/p&gt;

&lt;p&gt;If it doesn’t come from CI, it doesn’t get signed.&lt;/p&gt;

&lt;p&gt;This effectively makes the CI pipeline the &lt;strong&gt;root of trust&lt;/strong&gt; for all artifacts.&lt;/p&gt;




&lt;h2&gt;
  
  
  Signing with Cosign
&lt;/h2&gt;

&lt;p&gt;Cosign attaches a cryptographic signature to OCI images.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cosign sign &lt;span class="nt"&gt;--key&lt;/span&gt; cosign.key ghcr.io/&amp;lt;repo&amp;gt;/&amp;lt;image&amp;gt;:&amp;lt;tag&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verification:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cosign verify &lt;span class="nt"&gt;--key&lt;/span&gt; cosign.pub ghcr.io/&amp;lt;repo&amp;gt;/&amp;lt;image&amp;gt;:&amp;lt;tag&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Signatures are stored directly in the OCI registry as artifacts.&lt;/p&gt;




&lt;h2&gt;
  
  
  Kyverno enforcement
&lt;/h2&gt;

&lt;p&gt;Kyverno enforces image verification at admission time using a ClusterPolicy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;kyverno.io/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ClusterPolicy&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;verify-signed-images&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;validationFailureAction&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Enforce&lt;/span&gt;
  &lt;span class="na"&gt;background&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;

  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;check-signature&lt;/span&gt;
      &lt;span class="na"&gt;match&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;kinds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;Pod&lt;/span&gt;

      &lt;span class="na"&gt;verifyImages&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;imageReferences&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ghcr.io/&amp;lt;repo&amp;gt;/*"&lt;/span&gt;
          &lt;span class="na"&gt;attestors&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;entries&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
                &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;keys&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
                    &lt;span class="na"&gt;publicKeys&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
                      &lt;span class="s"&gt;-----BEGIN PUBLIC KEY-----&lt;/span&gt;
                      &lt;span class="s"&gt;...&lt;/span&gt;
                      &lt;span class="s"&gt;-----END PUBLIC KEY-----&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At runtime Kyverno:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Extracts image reference from Pod&lt;/li&gt;
&lt;li&gt;Resolves immutable digest&lt;/li&gt;
&lt;li&gt;Fetches Cosign signature from registry&lt;/li&gt;
&lt;li&gt;Verifies signature&lt;/li&gt;
&lt;li&gt;Allows or denies Pod creation&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  What happens in practice
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Unsigned image
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;No valid signature found&lt;/li&gt;
&lt;li&gt;Kyverno rejects Pod at admission&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Signed image
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Signature verified successfully&lt;/li&gt;
&lt;li&gt;Pod is admitted into the cluster&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The interesting bit:&lt;/p&gt;

&lt;p&gt;even if someone manually pushes an image to the registry, it still won’t run.&lt;/p&gt;

&lt;p&gt;The cluster doesn’t trust the registry — it trusts the signature.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why MicroK8s
&lt;/h2&gt;

&lt;p&gt;MicroK8s was used as a lightweight lab environment to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;test Kyverno policies locally&lt;/li&gt;
&lt;li&gt;simulate admission control behavior&lt;/li&gt;
&lt;li&gt;iterate quickly on Cosign integration&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Key takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;GitLab CI/CD becomes a &lt;strong&gt;trust anchor&lt;/strong&gt; when combined with Cosign&lt;/li&gt;
&lt;li&gt;Kyverno enforces security at &lt;strong&gt;admission time, not runtime&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;OCI registry acts as a &lt;strong&gt;provenance carrier&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;End-to-end supply chain security is achievable with minimal tooling&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Closing thought
&lt;/h2&gt;

&lt;p&gt;This experiment shows how Kubernetes supply chain security can be enforced end-to-end using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GitLab CI/CD for build and signing&lt;/li&gt;
&lt;li&gt;Cosign for cryptographic provenance&lt;/li&gt;
&lt;li&gt;Kyverno for policy enforcement&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Result:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Only verified and signed workloads can run in the cluster.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Repository
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/trottomv/microk8s-cosign-kyverno" rel="noopener noreferrer"&gt;https://github.com/trottomv/microk8s-cosign-kyverno&lt;/a&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>devops</category>
      <category>devsecops</category>
    </item>
    <item>
      <title>AI agent observability with OpenTelemetry and Grafana LGTM</title>
      <dc:creator>Matteo Vitali</dc:creator>
      <pubDate>Sun, 13 Jul 2025 06:52:39 +0000</pubDate>
      <link>https://dev.to/trottomv/ai-agent-observability-with-opentelemetry-and-grafana-lgtm-4m57</link>
      <guid>https://dev.to/trottomv/ai-agent-observability-with-opentelemetry-and-grafana-lgtm-4m57</guid>
      <description>&lt;p&gt;AI is powerful. But why does observing it matter?&lt;/p&gt;

&lt;p&gt;AI agents are becoming more and more common in production. However, they often behave like black boxes: we send a prompt, we get a response… but what happens in between?&lt;/p&gt;

&lt;p&gt;In this post, I’ll show why instrumenting AI agents matters more than ever, using open source tools like OpenTelemetry and the Grafana LGTM stack — that is, Loki, Grafana, Tempo, and Mimir (and yes, also “Looks Good To Me”! 😉).&lt;/p&gt;

&lt;h1&gt;
  
  
  The challenge
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;LLMs and AI agents are 'black boxes' systems:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Complex, &lt;strong&gt;non-deterministic&lt;/strong&gt; behavior&lt;/li&gt;
&lt;li&gt;Internal &lt;strong&gt;'reasoning' is invisible at runtime&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hard to explain&lt;/strong&gt;, trust, or debug &lt;strong&gt;outputs&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🛡️ “You can’t govern or secure what you can’t observe.” (semicit.)&lt;/p&gt;

&lt;h1&gt;
  
  
  An open standards-based approach
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;The OWASP Agent Observability Standard (AOS)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://aos.owasp.org" rel="noopener noreferrer"&gt;OWASP AOS&lt;/a&gt; wants to bring standardized observability to AI systems:&lt;br&gt;
Mission: Transform AI agents from black boxes into trustworthy systems through standardized observability.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Instrumentation&lt;/strong&gt; – via OpenTelemetry&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Traceability&lt;/strong&gt; – end-to-end execution flow&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inspectability&lt;/strong&gt; – insights on inner workings&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  OpenTelemetry
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://opentelemetry.io/" rel="noopener noreferrer"&gt;OpenTelemetry&lt;/a&gt; is a CNCF project that provides a standardized framework for telemetry:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Logs&lt;/strong&gt; (timestamped events)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Metrics&lt;/strong&gt; (numerical KPIs)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Traces&lt;/strong&gt; (end-to-end execution paths)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It supports manual and auto instrumentation, and works with many backends — including the Grafana LGTM stack.&lt;/p&gt;
&lt;h3&gt;
  
  
  💻 Manual instrumentation (code based)
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from openai import OpenAI
from opentelemetry.instrumentation.openai_v2 import OpenAIInstrumentor

OpenAIInstrumentor().instrument()

client = OpenAI()
response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[
      {
        "role": "user", 
        "content": "Write a short poem on OpenTelemetry."
      }
    ],
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  ⚡ Auto instrumentation (zero code)
&lt;/h3&gt;

&lt;p&gt;Alternatively, you can automatically instrument a Python app with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM python:3.13-alpine

ENV OTEL_EXPORTER_OTLP_ENDPOINT=otel-collector:4317

RUN pip install --no-cache-dir \
  fastapi \
  opentelemetry-distro \
  opentelemetry-instrumentation

COPY main.py .

CMD ["opentelemetry-instrument", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  📦 The OpenTelemetry Collector
&lt;/h3&gt;

&lt;p&gt;A key component for managing telemetry data&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318
  hostmetrics:  # otel-collector-contrib
    root_path: "/hostfs"
    collection_interval: 10s

processors:
  batch:
  resourcedetection:
    detectors: ["env", "system"]

exporters:
  otlp/traces:
    endpoint: tempo:4317
  otlphttp/metrics:
    endpoint: http://mimir:9009/otlp
  otlphttp/logs:
    endpoint: http://loki:3100/otlp

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch, resourcedetection]
      exporters: [otlp/traces]
    metrics:
      receivers: [otlp, hostmetrics]
      processors: [batch, resourcedetection]
      exporters: [otlphttp/metrics]
    logs:
      receivers: [otlp]
      processors: [batch, resourcedetection]
      exporters: [otlphttp/logs]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Observability with OpenTelemetry and Grafana LGTM
&lt;/h2&gt;

&lt;p&gt;Once data flows through the collector, the &lt;a href="https://grafana.com/" rel="noopener noreferrer"&gt;Grafana&lt;/a&gt; LGTM stack lets you explore:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Logs in Loki&lt;/li&gt;
&lt;li&gt;Metrics in Mimir&lt;/li&gt;
&lt;li&gt;Traces in Tempo&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6djsagnglbv11zadn5ne.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6djsagnglbv11zadn5ne.png" alt=" " width="748" height="782"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  PydanticAI agent instrumentation
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://ai.pydantic.dev/" rel="noopener noreferrer"&gt;PydanticAI&lt;/a&gt; is a Pythonic AI agent framework with native OpenTelemetry support&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pydantic_ai import Agent

agent = Agent(
    'google-gla:gemini-2.0-flash',
    system_prompt='Be concise, reply with one sentence.',
    instrument=True,
)

result = agent.run_sync('Where does "hello world" come from?')
print(result.output)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  📈 Inspect telemetry data
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdtzgifnqre5a9ilrowzq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdtzgifnqre5a9ilrowzq.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbiysnx2uiiqmuy9iivxb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbiysnx2uiiqmuy9iivxb.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  🤔 Final thoughts &amp;amp; takeaways
&lt;/h1&gt;

&lt;p&gt;Even the simplest “hello world” AI agent can be observed via metrics and traces, revealing how complex and resource-hungry LLM calls are,&lt;br&gt;
benefit from structured observability for debugging and trust building.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No business, No logic&lt;/strong&gt;
The AI agent is kept intentionally simple — a basic “hello world” — because the primary goal is to validate the power of observability in the context of agentic AI, not to showcase advanced intelligence.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Analytical and empirical evaluation&lt;/strong&gt;
With OpenTelemetry and Grafana, it's possible to analyze the agent both quantitatively (through metrics and traces) and qualitatively (by observing its flow), demonstrating the real value of observability in monitoring and understanding AI systems.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Conscious use of AI – Sometimes “a cannon is too much for a fly”&lt;/strong&gt;
Even a minimal AI agent benefits greatly from structured observability — it’s essential for understanding, debugging, and building trust. At the same time, it reveals a key insight: generating trivial output can come with a high computational cost, especially when relying on LLMs.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aiops</category>
      <category>observability</category>
      <category>opentelemetry</category>
      <category>grafana</category>
    </item>
    <item>
      <title>Secure by design in Python: A FastAPI app with 5 DevSecOps tools and a real time SSTI vulnerability remediation</title>
      <dc:creator>Matteo Vitali</dc:creator>
      <pubDate>Sat, 10 May 2025 07:46:16 +0000</pubDate>
      <link>https://dev.to/trottomv/secure-by-design-in-python-a-fastapi-app-with-5-devsecops-tools-and-a-real-time-ssti-vulnerability-2e6n</link>
      <guid>https://dev.to/trottomv/secure-by-design-in-python-a-fastapi-app-with-5-devsecops-tools-and-a-real-time-ssti-vulnerability-2e6n</guid>
      <description>&lt;h2&gt;
  
  
  🌟 Introduction
&lt;/h2&gt;

&lt;p&gt;Security should not be an afterthought in software development. Instead, it should be a core principle baked into your design, code, and CI/CD workflows. &lt;br&gt;
To demonstrate this approach, I've created an intentionally insecure FastAPI app as a playground. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/trottomv/python-insecure-app" rel="noopener noreferrer"&gt;https://github.com/trottomv/python-insecure-app&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this post, we'll walk through:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;5 open-source security tools (SCA, SAST, DAST, container scanning, API fuzzing)&lt;/li&gt;
&lt;li&gt;How they help uncover vulnerabilities&lt;/li&gt;
&lt;li&gt;How to remediate a &lt;strong&gt;real Server-Side Template Injection (SSTI)&lt;/strong&gt; vulnerability in FastAPI&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's dive in 👇&lt;/p&gt;


&lt;h2&gt;
  
  
  1️pip-audit: Python dependency vulnerability scanning
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip-audit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This tool checks for known vulnerabilities in your Python dependencies using safety-db or PyPI advisories. It's simple, fast, and effective.&lt;/p&gt;

&lt;p&gt;Sample output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jinja2 3.0.0 CVE-2022-XXXXX Template injection possible
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Remediation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Upgrade the affected package if a patched version is available&lt;/li&gt;
&lt;li&gt;Pin versions in &lt;code&gt;requirements.txt&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2️Bandit: static code analysis (SAST) for Python
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bandit &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Bandit performs static analysis on Python code to find common security issues like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use of dangerous functions (&lt;code&gt;eval&lt;/code&gt;, &lt;code&gt;exec&lt;/code&gt;, etc.)&lt;/li&gt;
&lt;li&gt;Hardcoded passwords or secrets&lt;/li&gt;
&lt;li&gt;Insecure file handling&lt;/li&gt;
&lt;li&gt;External calls with &lt;code&gt;requests&lt;/code&gt; without a timeout — which may lead to denial of service if the remote server hangs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;But:&lt;/strong&gt; Bandit currently &lt;strong&gt;does not detect Server-Side Template Injection (SSTI)&lt;/strong&gt;, even when using jinja2 templates unsafely.&lt;/p&gt;

&lt;p&gt;Reference: &lt;a href="https://github.com/PyCQA/bandit/issues/517" rel="noopener noreferrer"&gt;Issue #728&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This shows a limitation of SAST — it's useful, but &lt;strong&gt;not sufficient alone&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  3️Schemathesis: API fuzzing from OpenAPI schemas
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;schemathesis run http://localhost:8000/openapi.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Schemathesis generates test cases based on your OpenAPI schema and runs fuzzing-like checks on all endpoints.&lt;/p&gt;

&lt;p&gt;Benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Detects unexpected 500s and unhandled edge cases&lt;/li&gt;
&lt;li&gt;Validates assumptions in your parameter handling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In our demo, this helped uncover inconsistent behavior in the root &lt;code&gt;/&lt;/code&gt; endpoint, especially with template injection payloads.&lt;/p&gt;




&lt;h2&gt;
  
  
  4️Trivy: container image vulnerability scanner
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;trivy image trottomv/python-insecure-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Trivy scans for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OS package vulnerabilities (APT, APK, etc.)&lt;/li&gt;
&lt;li&gt;Python dependency CVEs&lt;/li&gt;
&lt;li&gt;Misconfigurations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Hardening tips:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;python:3.12-slim&lt;/code&gt; or smaller base images&lt;/li&gt;
&lt;li&gt;Avoid running as root (&lt;code&gt;USER app&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Consider introduce distroless approach&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bonus: Trivy also outputs SBOMs for compliance.&lt;/p&gt;




&lt;h2&gt;
  
  
  5️OWASP ZAP: dynamic app security testing (DAST)
&lt;/h2&gt;

&lt;p&gt;ZAP acts as a proxy or scanner against your running app (e.g. FastAPI on &lt;code&gt;localhost:8000&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;In our case, &lt;strong&gt;ZAP successfully discovered a Server-Side Template Injection (SSTI)&lt;/strong&gt; vulnerability:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;GET /?name={{7*6}} → "Hello 42!"
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This issue was &lt;strong&gt;not detected by Bandit&lt;/strong&gt;, highlighting the importance of dynamic analysis.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ Remediation: fixing the SSTI in FastAPI
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Vulnerable code:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# main.py
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;FastAPI&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi.responses&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;HTMLResponse&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;jinja2&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Template&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;FastAPI&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="nd"&gt;@app.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response_class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;HTMLResponse&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;try_hack_me&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;John Ripper&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;h1&amp;gt;Hello, &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;!&amp;lt;/h1&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Template&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why it's dangerous:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Template(content).render()&lt;/code&gt; evaluates the string using Jinja2, which allows remote code execution if input is unsanitized&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Secure fix:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# main.py
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;FastAPI&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi.responses&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;HTMLResponse&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;jinja2&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Template&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;FastAPI&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="nd"&gt;@app.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response_class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;HTMLResponse&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;try_hack_me&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;John Ripper&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;h1&amp;gt;Hello, {{name}}!&amp;lt;/h1&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Template&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Test it:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# tests.py
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi.testclient&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;TestClient&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;

&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;TestClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;test_root&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/?name={{7*6}}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;42&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  ✅ Conclusion
&lt;/h2&gt;

&lt;p&gt;Security is not a tool — it's a mindset and a workflow.&lt;/p&gt;

&lt;p&gt;Combining:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;pip-audit&lt;/code&gt; for software composition analysis&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;bandit&lt;/code&gt; for static code issues&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;schemathesis&lt;/code&gt; for fuzzing testing on APIs&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;trivy&lt;/code&gt; for vulnerability scanning and SBOMs generation on artifacts&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;zap&lt;/code&gt; for dynamic runtime scanning&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;...provides &lt;strong&gt;layered defense&lt;/strong&gt;. Fixing real issues like SSTI shows how practical this approach is.&lt;/p&gt;

&lt;p&gt;If you're curious:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🌐 Try the &lt;a href="https://github.com/trottomv/python-insecure-app" rel="noopener noreferrer"&gt;demo app&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;✏️ Suggest improvements or contribute new findings&lt;/li&gt;
&lt;li&gt;🚀 Integrate these tools in your next CI/CD pipeline&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Stay secure ✨&lt;/p&gt;




</description>
      <category>python</category>
      <category>devsecops</category>
      <category>security</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Boost your Django projects's security with proper `Cache-Control` on views</title>
      <dc:creator>Matteo Vitali</dc:creator>
      <pubDate>Sun, 19 Jan 2025 08:46:39 +0000</pubDate>
      <link>https://dev.to/trottomv/boost-your-django-projectss-security-with-proper-cache-control-on-views-546k</link>
      <guid>https://dev.to/trottomv/boost-your-django-projectss-security-with-proper-cache-control-on-views-546k</guid>
      <description>&lt;p&gt;Caching is great for performance, but sensitive data must never be cached! In Django, properly configuring Cache Control on your views ensures secure handling of sensitive content, such as login pages or user-specific data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔒 Why is Cache Control important?&lt;/strong&gt;&lt;br&gt;
Without proper cache settings, sensitive data may be stored in the user's browser or intermediary proxies, exposing it to potential risks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;💡 How to configure Cache Control in Django?&lt;/strong&gt;&lt;br&gt;
You can use the &lt;code&gt;@never_cache&lt;/code&gt; decorator on function-based views to prevent them from being cached (as mentioned in the &lt;a href="https://docs.djangoproject.com/en/5.1/topics/http/decorators/#django.views.decorators.cache.never_cache" rel="noopener noreferrer"&gt;official documentation&lt;/a&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.views.decorators.cache&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;never_cache&lt;/span&gt;  

&lt;span class="nd"&gt;@never_cache&lt;/span&gt;  
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;my_secure_view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;  
    &lt;span class="c1"&gt;# Your secure logic here  
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;HttpResponse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;This page is protected from caching!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But what if you want to reuse this logic across multiple class-based views? &lt;strong&gt;You can create a reusable mixin&lt;/strong&gt; for this purpose!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# myproject/views.py
&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.contrib.auth.mixins&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;LoginRequiredMixin&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.utils.decorators&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;method_decorator&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.views.decorators.cache&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;never_cache&lt;/span&gt;

&lt;span class="nd"&gt;@method_decorator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;never_cache&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;dispatch&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PrivateAreaMixin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;LoginRequiredMixin&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Override LoginRequiredMixin by adding Cache-Control rules.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this mixin, securing your class-based views becomes much simpler:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# myapp/views.py
&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.views.generic&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;TemplateView&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;myproject.views&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;PrivateAreaMixin&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;IndexView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PrivateAreaMixin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;TemplateView&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;The index view.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

    &lt;span class="n"&gt;template_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;index.html&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;🛠 Testing the Implementation&lt;/strong&gt;&lt;br&gt;
Testing is crucial to ensure everything works as expected. Here's how you can test the &lt;code&gt;PrivateAreaMixin&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# myproject/tests/test_views.py
&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.test&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;TestCase&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;RequestFactory&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.contrib.auth.models&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;AnonymousUser&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.contrib.auth&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;get_user_model&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.http&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;HttpResponse&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.views&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;View&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;myproject.views&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;PrivateAreaMixin&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PrivateAreaMixinTest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TestCase&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Test private area Cache-Control override.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

    &lt;span class="n"&gt;factory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;RequestFactory&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="nd"&gt;@classmethod&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;setUpTestData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cls&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Initialize test data.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
        &lt;span class="n"&gt;cls&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;get_user_model&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create_user&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;testuser&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
            &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user@test.xyz&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
            &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;5tr0ngP4ssW0rd&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;test_login_required_with_cache_control&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Test login required and Cache-Control dispatched.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

        &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PrivateAreaMixin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;View&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;HttpResponse&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

        &lt;span class="n"&gt;view&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;AView&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;as_view&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

        &lt;span class="c1"&gt;# Test redirect for anonymous users
&lt;/span&gt;        &lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;factory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;AnonymousUser&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assertEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;302&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assertEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/accounts/login/?next=/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c1"&gt;# Test authenticated user and cache control headers
&lt;/span&gt;        &lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;factory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;
        &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assertEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assertIn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Cache-Control&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assertEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Cache-Control&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;max-age=0, no-cache, no-store, must-revalidate, private&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;🔥 Best Practice Tip:&lt;/strong&gt;&lt;br&gt;
Using &lt;code&gt;@never_cache&lt;/code&gt; with a mixin like &lt;code&gt;PrivateAreaMixin&lt;/code&gt; makes your code reusable and clean. Combined with rigorous testing, this ensures your sensitive views remain secure and aligned with best practices.&lt;/p&gt;

&lt;p&gt;How do you handle caching and sensitive data in your Django projects?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Update:&lt;/em&gt;&lt;br&gt;
I’m excited to share that I’ve developed a new package, &lt;a href="https://pypi.org/project/django-never-cache/" rel="noopener noreferrer"&gt;django-never-cache&lt;/a&gt;, inspired by the concepts expressed in this post.&lt;/p&gt;

&lt;p&gt;This lightweight package simplifies applying Cache-Control rules to sensitive views by providing reusable utilities like mixins, middlewares and decorators. It is designed to make securing Django applications easier.&lt;/p&gt;

&lt;p&gt;Check it out on GitHub: &lt;a href="https://github.com/trottomv/django-never-cache" rel="noopener noreferrer"&gt;https://github.com/trottomv/django-never-cache&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to try it out, share feedback, or even contribute to its development. 🚀&lt;/p&gt;

</description>
      <category>django</category>
      <category>cache</category>
      <category>webdev</category>
      <category>python</category>
    </item>
  </channel>
</rss>
