<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Alan Darma Saputra on Medium]]></title>
        <description><![CDATA[Stories by Alan Darma Saputra on Medium]]></description>
        <link>https://medium.com/@alandrma?source=rss-f1984a0833fb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*YbrL_ZeiR_zeH3z9</url>
            <title>Stories by Alan Darma Saputra on Medium</title>
            <link>https://medium.com/@alandrma?source=rss-f1984a0833fb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 13:13:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alandrma/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Beyond SAST: Adding SCA, Container Security & DefectDojo to Your CI/CD Pipeline]]></title>
            <link>https://alandrma.medium.com/beyond-sast-adding-sca-container-security-defectdojo-to-your-ci-cd-pipeline-78a90459ed8e?source=rss-f1984a0833fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/78a90459ed8e</guid>
            <dc:creator><![CDATA[Alan Darma Saputra]]></dc:creator>
            <pubDate>Wed, 04 Jun 2025 10:01:16 GMT</pubDate>
            <atom:updated>2025-06-04T10:01:16.453Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*zkLo0t-_kme6W4Xz.jpeg" /></figure><h3>Introduction</h3><p>In our previous article, we covered implementing SAST security scanning and some DAST in GitLab CI/CD with Jenkins. While SAST is great for finding code vulnerabilities, modern applications need more comprehensive security coverage. Today, we’ll extend our pipeline with three key additions: Software Composition Analysis (SCA), container security scanning, and DefectDojo for centralized vulnerability management.</p><p>This upgrade transforms our basic security scanning into a complete DevSecOps solution that covers the entire application stack.</p><h3>Why We Need More Than SAST</h3><p>SAST only scans the code you write, but modern applications are mostly built using third-party libraries and dependencies. Studies show that 70–90% of application code comes from external sources. A single vulnerable dependency can compromise your entire application.</p><p>Additionally, if you’re using containers (and most teams are), you need to scan the container images for vulnerabilities in the base OS, installed packages, and configurations. SAST won’t catch these issues.</p><ul><li><strong>Software Composition Analysis (SCA)</strong> for dependency vulnerability scanning</li><li><strong>Container Security Scanning</strong> for Docker image vulnerabilities</li><li><strong>Centralized Security Management</strong> with DefectDojo integration</li><li><strong>Advanced Reporting and Metrics</strong> for security governance</li></ul><p>This evolution transforms our basic SAST implementation into a robust, enterprise-ready security pipeline that addresses the full spectrum of application security concerns.</p><p>Finally, managing findings from multiple security tools becomes chaotic without a central system to correlate, prioritize, and track remediation efforts.</p><h3>Architecture Overview</h3><p>Our enhanced security pipeline now incorporates multiple scanning layers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*by7DYM5RkciXE-CUjD2gYg.png" /><figcaption>Architecture Overview</figcaption></figure><h3>Software Composition Analysis (SCA)</h3><p>SCA tools scan your dependencies and third-party libraries for known vulnerabilities. They work by:</p><ul><li>Identifying all dependencies in your project</li><li>Checking them against vulnerability databases</li><li>Reporting known security issues</li><li>Monitoring for new vulnerabilities in your dependencies</li></ul><p>The key benefit is visibility into your supply chain risks. You’ll discover vulnerabilities you never knew existed and can prioritize updates based on actual risk.</p><p>Popular SCA tools include Snyk, OWASP Dependency-Check, and commercial solutions like Veracode SCA. Most integrate easily into CI/CD pipelines and can be configured to fail builds when high-severity vulnerabilities are found.</p><h3>Part 1: Implementing Snyk SCA (Software Composition Analysis)</h3><h4>Setting Up Snyk SCA</h4><p>Configure Snyk SCA in your GitLab CI/CD pipeline:</p><pre>snyk-sca:<br>  stage: security-scan<br>  before_script:<br>    - export PATH=$PATH:/usr/local/go/bin<br>    - snyk auth &quot;$SNYK_TOKEN&quot; || true<br>  script:<br>    - |<br>      echo &quot;[INFO] Running Snyk SCA scan...&quot;<br>      set -e<br>      # Python<br>      if [ -f requirements.txt ]; then<br>        echo &quot;Python project detected. Setting up virtual environment...&quot;<br>        python3 -m venv venv #Change to python2 if python2 is used<br>        source venv/bin/activate<br>        pip3 install --upgrade pip<br>        pip3 install -r requirements.txt<br>      else<br>        echo &quot;No Python project (requirements.txt not found)&quot;<br>      fi<br><br>      # Go<br>      if [ -f go.mod ]; then<br>        echo &quot;Go project detected. Downloading modules...&quot;<br>        go mod download<br>      else<br>        echo &quot;No Go project (go.mod not found)&quot;<br>      fi<br><br>      # Node.js<br>      if [ -f package.json ]; then<br>        echo &quot;Node.js project detected. Installing npm packages...&quot;<br>        npm install<br>      else<br>        echo &quot;No Node.js project (package.json not found)&quot;<br>      fi<br><br>      # Maven<br>      if [ -f pom.xml ]; then<br>        echo &quot;Maven project detected. Resolving dependencies...&quot;<br>        mvn dependency:resolve<br>      else<br>        echo &quot;No Maven project (pom.xml not found)&quot;<br>      fi<br><br>      # Gradle<br>      if ls build.gradle* 1&gt; /dev/null 2&gt;&amp;1; then<br>        echo &quot;Gradle project detected. Running Gradle build...&quot;<br>        gradle build<br>      else<br>        echo &quot;No Gradle project (build.gradle not found)&quot;<br>      fi<br><br>      # .NET<br>      if ls *.csproj 1&gt; /dev/null 2&gt;&amp;1; then<br>        echo &quot;.NET project detected. Restoring packages...&quot;<br>        dotnet restore<br>      else<br>        echo &quot;No .NET project (*.csproj not found)&quot;<br>      fi<br><br>      set +e<br>      DRY_RUN_OUTPUT=$(snyk test --dry-run --json)<br>      DRY_RUN_OUTPUT=$(snyk test --dry-run --json --detection-depth=4 --json-file-output=snyk_report.json)<br>      echo &quot;$DRY_RUN_OUTPUT&quot;<br>      echo &quot;$DRY_RUN_OUTPUT&quot; | grep -E &#39;&quot;error&quot;: &quot;Failed to test|Could not detect supported target files&#39; &gt; /dev/null<br>      if [ $? -eq 0 ]; then<br>        echo &quot;No supported projects found by Snyk. Skipping test.&quot;<br>        echo &#39;{}&#39; &gt; snyk_report.json  # Create dummy report to avoid artifact error<br>        exit 0<br>      fi<br>      <br>      cp snyk_report.json &quot;$SNYK_OUTPUT_DIR/$SNYK_REPORT_FILENAME&quot;<br>      echo &quot;[INFO] Snyk SCA scan report:&quot;<br>      cat snyk_report.json<br>  allow_failure: false<br>  artifacts:<br>    paths:<br>      - snyk_report.json</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wI3SF6SpkyCBEdY1L2LKzA.png" /><figcaption>Gitlab CI/CD Pipeline</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cAIN_YPPYQegGrSFWrFCmg.png" /><figcaption>Results pipeline Snyk SCA</figcaption></figure><h3>Container Security Scanning</h3><p>Container security scanning examines your Docker images for vulnerabilities across multiple layers:</p><ul><li>Base OS vulnerabilities</li><li>Installed package vulnerabilities</li><li>Configuration issues</li><li>Secret detection in images</li></ul><p>Tools like Trivy, Clair, or Anchore scan container images and generate detailed reports. The scanning can happen during build time (before pushing to registry) and at runtime (scanning running containers).</p><p>Container scanning is particularly important because vulnerabilities in base images affect all containers built from them. A single vulnerable base image can impact dozens of applications.</p><h3>Part 2: Container Security Scanning with Trivy and Grype</h3><h3>Implementing Trivy Container Scanning</h3><p>Trivy provides comprehensive container vulnerability and misconfiguration scanning:</p><pre>        stage(&#39;Scan with Trivy&#39;) {<br>            steps {<br>                dir(&quot;${APP_DIR}&quot;) {<br>                    sh &#39;&#39;&#39;<br>                        echo &quot;🔍 Starting Trivy scan...&quot;<br>                        docker run --rm \<br>                            -v /var/run/docker.sock:/var/run/docker.sock \<br>                            -v $(pwd)/trivy-output:/root/reports \<br>                            aquasec/trivy image --format json \<br>                            -o /root/reports/trivy-report.json ${DOCKER_IMAGE}<br>                    &#39;&#39;&#39;<br>                }<br>            }<br>        }</pre><h3>Implementing Grype Container Scanning</h3><p>Grype provides additional container vulnerability scanning capabilities:</p><pre>        stage(&#39;Scan with Grype&#39;) {<br>            steps {<br>                dir(&quot;${APP_DIR}&quot;) {<br>                    sh &#39;&#39;&#39;<br>                        echo &quot;🔍 Starting Grype scan...&quot;<br>                        mkdir -p grype-output<br>                        docker run --rm \<br>                            -v /var/run/docker.sock:/var/run/docker.sock \<br>                            -v $(pwd)/grype-output:/tmp \<br>                            --name grype anchore/grype:latest ${DOCKER_IMAGE} \<br>                            -o json &gt; grype-output/grype-report.json<br>                    &#39;&#39;&#39;<br>                }<br>            }<br>        }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PpPkxbwvAfwQQKvn.jpg" /></figure><h3>DefectDojo: Your Security Configuration Management</h3><p>DefectDojo is an open-source vulnerability management platform that becomes your single source of truth for all security findings. It solves several problems:</p><p><strong>Centralization</strong>: Instead of checking multiple tools and dashboards, everything flows into DefectDojo.</p><p><strong>Deduplication</strong>: The same vulnerability found by different tools only appears once.</p><p><strong>Workflow Management</strong>: Assign findings to teams, track remediation progress, and set SLAs.</p><p><strong>Reporting</strong>: Generate compliance reports and security metrics for management.</p><p>DefectDojo supports imports from 100+ security tools, making it perfect for our multi-tool approach.</p><h3>Part 3: DefectDojo Integration Scripts</h3><h4>DefectDojo Uploader Script</h4><pre>        stage(&#39;Upload Trivy to DefectDojo&#39;) {<br>            steps {<br>                dir(&quot;${APP_DIR}&quot;) {<br>                    sh &#39;&#39;&#39;<br>                        echo &quot;⬆️ Uploading Trivy report to DefectDojo...&quot;<br>                        curl -k -H &quot;Authorization: Token ${DEFECTDOJO_API_KEY}&quot; \<br>                            -F &quot;engagement=30&quot; \<br>                            -F &quot;scan_type=Trivy Scan&quot; \<br>                            -F &quot;file=@trivy-output/trivy-report.json&quot; \<br>                            -F &quot;verified=true&quot; \<br>                            -F &quot;active=true&quot; \<br>                            ${DEFECTDOJO_URL}/api/v2/import-scan/<br>                    &#39;&#39;&#39;<br>                }<br>            }<br><br>        stage(&#39;Upload Grype to DefectDojo&#39;) {<br>            steps {<br>                dir(&quot;${APP_DIR}&quot;) {<br>                    sh &#39;&#39;&#39;<br>                        echo &quot;⬆️ Uploading Grype report to DefectDojo...&quot;<br>                        curl -k -H &quot;Authorization: Token ${DEFECTDOJO_API_KEY}&quot; \<br>                            -F &quot;engagement=28&quot; \<br>                            -F &quot;scan_type=Anchore Grype&quot; \<br>                            -F &quot;file=@grype-output/grype-report.json&quot; \<br>                            -F &quot;verified=true&quot; \<br>                            -F &quot;active=true&quot; \<br>                            ${DEFECTDOJO_URL}/api/v2/import-scan/<br>                    &#39;&#39;&#39;<br>                }<br>            }<br>        }<br><br>        stage(&#39;Upload Nikto to DefectDojo&#39;) {<br>            steps {<br>                dir(&quot;${APP_DIR}&quot;) {<br>                    sh &#39;&#39;&#39;<br>                        echo &quot;⬆️ Uploading Nikto report to DefectDojo...&quot;<br>                        curl -k -H &quot;Authorization: Token ${DEFECTDOJO_API_KEY}&quot; \<br>                            -F &quot;engagement=29&quot; \<br>                            -F &quot;scan_type=Nikto Scan&quot; \<br>                            -F &quot;file=@nikto-output/nikto-report.json&quot; \<br>                            -F &quot;verified=true&quot; \<br>                            -F &quot;active=true&quot; \<br>                            ${DEFECTDOJO_URL}/api/v2/import-scan/<br>                    &#39;&#39;&#39;<br>                }<br>            }<br>        }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4wnnhHWDl8Ow2oqJnuxnRQ.png" /><figcaption>Findings on Defectdojo</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZOt53HX3IWSU95PmQv_mXg.png" /><figcaption>All engagement in Defectdojo</figcaption></figure><h3>Benefits You’ll See</h3><p><strong>Better Coverage</strong>: Catch vulnerabilities in dependencies and containers that SAST misses.</p><p><strong>Reduced Noise</strong>: DefectDojo’s deduplication and correlation reduce alert fatigue.</p><p><strong>Faster Response</strong>: Centralized workflow management speeds up remediation.</p><p><strong>Compliance</strong>: Comprehensive scanning and reporting support compliance requirements.</p><p><strong>Team Efficiency</strong>: Developers get clearer, prioritized security feedback instead of overwhelming tool output.</p><h3>Common Challenges and Solutions</h3><p><strong>Performance Impact</strong>: Multiple scans can slow builds. Solution: Run scans in parallel and cache results when possible.</p><p><strong>False Positives</strong>: More tools mean more false positives. Solution: Use DefectDojo’s workflow features to mark false positives and improve accuracy over time.</p><p><strong>Tool Maintenance</strong>: Managing multiple security tools requires overhead. Solution: Standardize on tools with good API support and automate configuration management.</p><p><strong>Developer Adoption</strong>: Security complexity can frustrate developers. Solution: Focus on clear, actionable feedback and integrate security into existing workflows.</p><h3>Measuring Success</h3><p>Track these key metrics to demonstrate value:</p><ul><li><strong>Vulnerability Detection Time</strong>: How quickly you find new vulnerabilities</li><li><strong>Mean Time to Remediation</strong>: How fast vulnerabilities get fixed</li><li><strong>Coverage Metrics</strong>: Percentage of applications with comprehensive scanning</li><li><strong>Risk Reduction</strong>: Decrease in high/critical vulnerabilities over time</li><li><strong>Process Efficiency</strong>: Reduction in manual security review time</li></ul><h3>Conclusion</h3><p>Extending your SAST implementation with SCA, container security, and DefectDojo creates a robust DevSecOps pipeline that provides comprehensive security coverage. The key is implementing incrementally and focusing on practical value rather than perfect coverage from day one.</p><p>Your development teams will appreciate the clearer security feedback, security teams will love the centralized visibility, and management will see measurable improvements in your security posture. Most importantly, your applications will be significantly more secure against the threats that matter most in today’s landscape.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78a90459ed8e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing Comprehensive SAST Security Scanning in GitLab CI/CD with Jenkins Integration]]></title>
            <link>https://alandrma.medium.com/implementing-comprehensive-sast-security-scanning-in-gitlab-ci-cd-with-jenkins-integration-c1b7629b3c80?source=rss-f1984a0833fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1b7629b3c80</guid>
            <category><![CDATA[dast]]></category>
            <category><![CDATA[defectdojo]]></category>
            <category><![CDATA[pipeline]]></category>
            <category><![CDATA[sast]]></category>
            <category><![CDATA[ci-cd-devops]]></category>
            <dc:creator><![CDATA[Alan Darma Saputra]]></dc:creator>
            <pubDate>Tue, 03 Jun 2025 09:21:15 GMT</pubDate>
            <atom:updated>2025-06-03T09:21:15.994Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/599/0*je2Nby79Hq4YbyRP.png" /><figcaption>CI/CD Pipeline</figcaption></figure><h3>Introduction</h3><p>Static Application Security Testing (SAST) has become an essential component of modern DevSecOps pipelines. In this article, I’ll walk you through a complete proof-of-concept implementation that integrates multiple SAST tools within GitLab CI/CD, coupled with Jenkins for containerized deployments and additional security scanning.</p><p>This implementation demonstrates a real-world approach to embedding security throughout the development lifecycle, from code commit to production deployment.</p><h3>Architecture Overview</h3><p>Our security pipeline consists of two main components:</p><ol><li><strong>GitLab CI/CD Pipeline</strong>: Handles multiple SAST tools, artifact management, and integration with security management platforms</li><li><strong>Jenkins Pipeline</strong>: Manages containerized builds, deployments, and runtime security scanning (DAST)</li></ol><p>The integration between these systems creates a comprehensive security scanning workflow that covers both static code analysis and dynamic application security testing.</p><h3>GitLab CI/CD Pipeline Implementation</h3><h3>Pipeline Structure</h3><pre>stages:<br>  - securityscan<br>  - debug<br>  - commit_results<br>  - trigger_jenkins<br>  - verify_jenkins</pre><p>Let’s dive into each stage in detail:</p><h3>Stage 1: Security Scan</h3><p>The security scan stage runs multiple SAST tools in parallel to maximize coverage and minimize pipeline execution time.</p><h4>Snyk Code Test</h4><pre>variables:<br>  # Your token here<br>  SNYK_TOKEN: $SNYK_TOKEN  # Set this in GitLab CI/CD variables<br><br>snyk-code-test:<br>  stage: securityscan<br>  script:<br>    - echo &quot;Running Snyk code test&quot;<br>    # Install Snyk CLI if not already installed on the runner<br>    - command -v snyk || npm install -g snyk<br>    # Authenticate with Snyk (if not using CI/CD variables for authentication)<br>    - snyk auth $SNYK_TOKEN<br>    # Run Snyk code test with JSON output<br>    - snyk code test --json &gt; snyk-results.json || true<br>    # Optionally - save the results as an artifact<br>    - echo &quot;Snyk code test completed. Results saved to snyk-results.json&quot;<br>    - cat snyk-results.json<br>  artifacts:<br>    paths:<br>      - snyk-results.json<br>    expire_in: 1 week<br>  # Run this job only on the main branch<br>  only:<br>    - main  # or master, depending on your default branch name\</pre><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hardZaNiDfein0Q1GS745Q.png" /></figure><p><strong>Purpose</strong>: Snyk provides comprehensive vulnerability detection for multiple programming languages and identifies security issues, license problems, and code quality issues.</p><p><strong>Key Features</strong>:</p><ul><li>Language-agnostic scanning</li><li>Integration with vulnerability databases</li><li>SARIF format output for standardized reporting</li><li>JSON output for custom processing</li></ul><h4>Gosec Scan</h4><pre>gosec-scan:<br>  stage: securityscan<br>  before_script:<br>    # Ensure gosec is available<br>    - export PATH=$PATH:/usr/local/bin:/usr/local/go/bin:$HOME/go/bin<br>    # If gosec is still not found, install it<br>    - which gosec || go install github.com/securego/gosec/v2/cmd/gosec@latest<br>  script:<br>    # Run gosec security scanner with tests and output to JSON file<br>    #- gosec -tests ./... | tee gosec-results.json || true<br>    - gosec -fmt=json -out=gosec-results.json ./... || true<br><br>  artifacts:<br>    paths:<br>      - gosec-results.json<br>    expire_in: 1 week</pre><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lf4KQKa8RrjspZRM0YGjOg.png" /></figure><p><strong>Purpose</strong>: Specialized Go security analyzer that identifies common security problems in Go code.</p><blockquote><strong><em>Note:</em></strong><em> You can append </em><em>|| true to the gosec scan command to bypass the scan results. This allows the CI/CD pipeline to continue even if security issues are detected.<br>For strict enforcement, remove </em><em>|| true so that the pipeline will fail and stop if any issues are found. This ensures that all identified vulnerabilities must be resolved before proceeding to the next stage.</em></blockquote><p><strong>Key Features</strong>:</p><ul><li>Go-specific security rules</li><li>Identifies SQL injection, XSS, and other common vulnerabilities</li><li>Low false-positive rate</li><li>Fast execution</li></ul><h4>TruffleHog Scan</h4><pre>trufflehog_scan:<br>  stage: securityscan<br>  script:<br>    - trufflehog git file://. --no-update --results=verified,unknown --json | tee trufflehog_results.json<br>  artifacts:<br>    paths:<br>      - trufflehog_results.json<br>    when: always<br>  allow_failure: true</pre><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UEqzkweGXCGhb0Rs3Zi4qA.png" /></figure><p><strong>Purpose</strong>: Searches for secrets, API keys, passwords, and other sensitive information in code repositories.</p><p><strong>Key Features</strong>:</p><ul><li>Git history scanning</li><li>High-entropy string detection</li><li>Custom regex patterns</li><li>Multiple output formats</li></ul><h4>Semgrep Scan</h4><pre>semgrep_scan:<br>  stage: securityscan<br>  #image: returntocorp/semgrep<br>  script:<br>    - semgrep --config=auto --json --output semgrep-report.json<br>  artifacts:<br>    paths:<br>      - semgrep-report.json<br>  allow_failure: false</pre><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YqKULfRyUiBsxk1cnR_cuA.png" /></figure><p><strong>Purpose</strong>: Fast, lightweight static analysis tool that finds bugs, security issues, and enforces code standards.</p><p><strong>Key Features</strong>:</p><ul><li>Multi-language support</li><li>Custom rule creation</li><li>Community-driven rule sets</li><li>Fast execution with minimal false positives</li></ul><h4>Gitleaks Scan</h4><pre>gitleaks:<br>  stage: securityscan<br>  script:<br>    # Run Gitleaks but don&#39;t let it fail the job immediately<br>    - gitleaks detect --report-format json --report-path gitleaks-output.json || true<br><br>    # Print for visibility<br>    - cat gitleaks-output.json<br><br>    # Fail manually if secrets found (check if &#39;findings&#39; array is not empty)<br>    - jq &#39;select(.findings | length &gt; 0)&#39; gitleaks-output.json | grep -q . &amp;&amp; exit 1 || true<br>  artifacts:<br>    paths:<br>      - gitleaks-output.json<br>  allow_failure: false</pre><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kRpFyLXlrh4EYENu4ZhKjw.png" /></figure><p><strong>Purpose</strong>: Detects and prevents secrets in git repositories.</p><p><strong>Key Features</strong>:</p><ul><li>Git-aware secret detection</li><li>Custom rule configuration</li><li>Historical commit scanning</li><li>Integration with CI/CD pipelines</li></ul><h3>Stage 2: Debug</h3><pre>debug_artifacts_location:<br>  stage: debug<br>  needs:<br>    - snyk-code-test<br>    - gosec-scan<br>    - trufflehog_scan<br>    - semgrep_scan<br>    - gitleaks<br>  script:<br>    - echo &quot;Current working directory:&quot;<br>    - pwd<br>    - echo &quot;List of files in current directory:&quot;<br>    - ls -lah<br>    - echo &quot;List of files in subdirectories (recursive):&quot;<br>    - find . -type f<br>  only:<br>    - main</pre><p><strong>Purpose</strong>: Provides visibility into artifact generation and helps troubleshoot pipeline issues.</p><p><strong>Note:</strong> The debug mode is intended to reveal the file paths where each tool’s scan results (artifacts) are stored. This makes it easier to locate and manage these artifacts when importing them into the SCM platform we use — in this case, DefectDojo.</p><h3>Stage 3: Commit Results</h3><pre>send_results_to_defectdojo:<br>  stage: commit_results<br>  needs:<br>    - snyk-code-test<br>    - gosec-scan<br>    - trufflehog_scan<br>    - semgrep_scan<br>    - gitleaks<br>  image: curlimages/curl:latest<br>  script:<br>    - echo &quot;Sending Snyk results to DefectDojo&quot;<br>    - |<br>      curl -X POST &quot;http://192.168.122.11:8080/api/v2/import-scan/&quot; \<br>        -H &quot;Authorization: Token $DEFECTDOJO_API_TOKEN&quot; \<br>        -F &quot;engagement=24&quot; \<br>        -F &quot;scan_type=Snyk Scan&quot; \<br>        -F &quot;file=@snyk-results.json&quot; \<br>        -F &quot;active=true&quot; \<br>        -F &quot;verified=true&quot;<br><br>    - echo &quot;Sending Gosec results to DefectDojo&quot;<br>    - |<br>      curl -X POST &quot;http://192.168.122.11:8080/api/v2/import-scan/&quot; \<br>        -H &quot;Authorization: Token $DEFECTDOJO_API_TOKEN&quot; \<br>        -F &quot;engagement=25&quot; \<br>        -F &quot;scan_type=Gosec Scanner&quot; \<br>        -F &quot;file=@gosec-results.json&quot; \<br>        -F &quot;active=true&quot; \<br>        -F &quot;verified=true&quot;<br><br>    - echo &quot;Sending Trufflehog results to DefectDojo&quot;<br>    - |<br>      curl -X POST &quot;http://192.168.122.11:8080/api/v2/import-scan/&quot; \<br>        -H &quot;Authorization: Token $DEFECTDOJO_API_TOKEN&quot; \<br>        -F &quot;engagement=26&quot; \<br>        -F &quot;scan_type=Trufflehog Scan&quot; \<br>        -F &quot;file=@trufflehog_results.json&quot; \<br>        -F &quot;active=true&quot; \<br>        -F &quot;verified=true&quot;<br><br>    - echo &quot;Sending Semgrep results to DefectDojo&quot;<br>    - |<br>      curl -X POST &quot;http://192.168.122.11:8080/api/v2/import-scan/&quot; \<br>        -H &quot;Authorization: Token $DEFECTDOJO_API_TOKEN&quot; \<br>        -F &quot;engagement=27&quot; \<br>        -F &quot;scan_type=Semgrep JSON Report&quot; \<br>        -F &quot;file=@semgrep-report.json&quot; \<br>        -F &quot;active=true&quot; \<br>        -F &quot;verified=true&quot;<br><br>    - echo &quot;Sending Gitleaks results to DefectDojo&quot;<br>    - |<br>      curl -X POST &quot;http://192.168.122.11:8080/api/v2/import-scan/&quot; \<br>        -H &quot;Authorization: Token $DEFECTDOJO_API_TOKEN&quot; \<br>        -F &quot;engagement=23&quot; \<br>        -F &quot;scan_type=Gitleaks Scan&quot; \<br>        -F &quot;file=@gitleaks-output.json&quot; \<br>        -F &quot;active=true&quot; \<br>        -F &quot;verified=true&quot;<br><br>  only:<br>    - main<br>  when: on_success</pre><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oLLbm-nt1gZ_l-OVDSnZWw.png" /><figcaption>Results send_results_to_defectdojo</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dxciq2ceA_zYsQ5K-SCUaw.png" /><figcaption>Product List Defectdojo</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D9U2EqiOjgsO2MFTF-aOLA.png" /><figcaption>Dashboard Defectdojo</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yqeevHBN9B00t8FcfWsY6g.png" /><figcaption>Findings in Defectdojo</figcaption></figure><p><strong>Purpose</strong>: Integrates scan results with DefectDojo for centralized security management and tracking.</p><p>DefectDojo serves as the centralized Security Control Management (SCM) platform in our pipeline, designed to streamline the handling of security findings. After executing the send_results_to_defectdojo step, all output artifacts generated by various security scanning tools are automatically uploaded into DefectDojo. Once imported, DefectDojo aggregates and organizes these findings into a structured dashboard, providing clear visibility into potential vulnerabilities across the codebase.</p><p>This centralized aggregation enables teams to track issues more effectively, assign them to the appropriate personnel, and monitor remediation progress over time. Additionally, DefectDojo maintains a historical log of findings, making it easier to reference past issues, observe trends, and apply versioning to track improvements or regressions in security posture. By integrating DefectDojo into the CI/CD workflow, we ensure that security is not treated as an afterthought but is embedded into the development lifecycle with full traceability and accountability.</p><h3>Stage 4: Trigger Jenkins</h3><pre>trigger_jenkins:<br>  stage: trigger_jenkins<br>  script:<br>    - echo &quot;Trigger Jenkins pipeline&quot;<br>  only:<br>    - main<br>  when: always<br>  after_script:<br>    - curl -X POST -u user:[YOUR TOKEN HERE] -H &quot;Jenkins-Crumb:[YOUR CRUMB HERE]&quot; http://192.168.122.11:9090/job/docker-demo-webapp/build</pre><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*menb95k-HOtYMec-Z3H9QA.png" /></figure><p><strong>Purpose</strong>: Triggers the Jenkins pipeline for containerized build and deployment.</p><h3>Stage 5: Verify Jenkins</h3><pre>verify_jenkins:<br>  stage: verify_jenkins<br>  script:<br>    - echo &quot;Verifying Jenkins job status&quot;<br>    - |<br>      JOB_STATUS=&quot;&quot;<br>      JOB_URL=&quot;http://192.168.122.11:9090/job/docker-demo-webapp/lastBuild/api/json&quot;<br>      AUTH=&quot;user:[YOUR TOKEN HERE]&quot;<br>      CRUMB=&quot;[YOUR CRUMB HERE]&quot;<br><br>      # Poll status max 10 kali dengan delay 15 detik<br>      for i in {1..10}; do<br>        echo &quot;Checking build status (attempt $i)...&quot;<br>        JOB_STATUS=$(curl -s -u $AUTH -H &quot;Jenkins-Crumb:$CRUMB&quot; $JOB_URL | jq -r &#39;.result&#39;)<br>        <br>        if [ &quot;$JOB_STATUS&quot; == &quot;SUCCESS&quot; ]; then<br>          echo &quot;Jenkins job succeeded!&quot;<br>          exit 0<br>        elif [ &quot;$JOB_STATUS&quot; == &quot;FAILURE&quot; ]; then<br>          echo &quot;Jenkins job failed!&quot;<br>          exit 1<br>        else<br>          echo &quot;Jenkins job still running or pending, waiting 15s...&quot;<br>          sleep 15<br>        fi<br>      done<br><br>      echo &quot;Jenkins job status check timed out.&quot;<br>      exit 1<br>  only:<br>    - main<br>  when: on_success</pre><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*AcBpU-bbutBYSVIR6GPuAQ.png" /></figure><p><strong>Purpose</strong>: Monitors the Jenkins build to ensure it completes successfully before marking the GitLab pipeline as complete.</p><p>In this stage, the pipeline performs a verification check to confirm whether Jenkins has successfully completed the deployment process. This step is critical to ensure that the build artifacts have been correctly deployed to the intended environment before continuing with post-deployment processes such as security validation, artifact export, or integration with SCM platforms.</p><p>By validating Jenkins deployment status, we reduce the risk of acting on incomplete or failed deployments. It provides a safeguard mechanism that ensures subsequent automation steps rely on a stable and verified deployment state. This stage typically involves checking Jenkins job status, pipeline stage completion, or querying deployment logs/output to determine success or failure. If the deployment has not occurred or failed, the pipeline can halt or notify the appropriate team to investigate further.</p><h3>Jenkins Pipeline Implementation</h3><p>The Jenkins pipeline handles containerized application builds, deployments, and runtime security testing.</p><h3>Stage 1: Build and Deploy</h3><h3>Jenkinsfile Structure</h3><pre>pipeline {<br>    agent any<br><br>    environment {<br>        APP_NAME = &#39;go-webapp&#39;<br>        DOCKER_IMAGE = &quot;${APP_NAME}:latest&quot;<br>        APP_DIR = &#39;/var/lib/jenkins/workspace&#39;<br>        NIKTO_DIR = &quot;${APP_DIR}/nikto&quot;<br>        NIKTO_IMAGE = &#39;sullo/nikto&#39;<br>        REPORT_PATH = &quot;${APP_DIR}/nikto-report.json&quot;<br>    }<br><br>    stages {<br>        stage(&#39;Checkout Code&#39;) {<br>            steps {<br>                dir(&quot;${APP_DIR}&quot;) {<br>                    git credentialsId: &#39;b04a5f6d-fbe3-4878-adf9-ef197657381d&#39;,<br>                        branch: &#39;main&#39;,<br>                        url: &#39;http://192.168.122.14/app-security/docker-demo-webapp.git&#39;<br>                }<br>            }<br>        }<br><br>        stage(&#39;Build Docker Image&#39;) {<br>            steps {<br>                dir(&quot;${APP_DIR}&quot;) {<br>                    sh &quot;docker build -t ${DOCKER_IMAGE} .&quot;<br>                }<br>            }<br>        }<br><br>        stage(&#39;Stop Existing App Container&#39;) {<br>            steps {<br>                sh &#39;&#39;&#39;<br>                    if [ $(docker ps -a -q -f name=^/go-webapp$) ]; then<br>                        echo &quot;🛑 Stopping and removing existing container go-webapp...&quot;<br>                        docker rm -f go-webapp<br>                    else<br>                        echo &quot;ℹ️ No existing container named go-webapp found.&quot;<br>                    fi<br>                &#39;&#39;&#39;<br>            }<br>        }<br><br>        stage(&#39;Deploy New Container&#39;) {<br>            steps {<br>                sh &quot;docker run -d --name ${APP_NAME} --network host -p 3001:3001 ${DOCKER_IMAGE}&quot;<br>            }<br>        }<br><br>        stage(&#39;Stop Existing Nikto Container&#39;) {<br>            steps {<br>                sh &#39;&#39;&#39;<br>                    if [ $(docker ps -a -q -f name=^/nikto$) ]; then<br>                        echo &quot;🛑 Stopping and removing existing container nikto...&quot;<br>                        docker rm -f nikto<br>                    else<br>                        echo &quot;ℹ️ No existing container named nikto found.&quot;<br>                    fi<br>                &#39;&#39;&#39;<br>            }<br>        }<br><br>        stage(&#39;Build Nikto Docker Image&#39;) {<br>            steps {<br>                dir(&quot;${APP_DIR}&quot;) {<br>                    sh &#39;&#39;&#39;<br>                        echo &quot;📥 Cloning Nikto source code...&quot;<br>                        rm -rf nikto<br>                        git clone https://github.com/sullo/nikto.git<br>                        cd nikto<br>                        echo &quot;🐳 Building Nikto Docker image...&quot;<br>                        docker build -t sullo/nikto .<br>                    &#39;&#39;&#39;<br>                }<br>            }<br>        }<br><br>        stage(&#39;DAST with Nikto&#39;) {<br>            steps {<br>                dir(&quot;${APP_DIR}&quot;) {<br>                    sh &#39;&#39;&#39;<br>                        echo &quot;🔍 Preparing Nikto output folder...&quot;<br>                        mkdir -p nikto-output<br>                        chmod 777 nikto-output<br>                        echo &quot;🔍 Starting Nikto scan using Docker...&quot;<br>                        docker run --rm -v $(pwd)/nikto-output:/tmp --network host --name nikto sullo/nikto \<br>                            -h http://localhost:3001 \<br>                            -o /tmp/nikto-report.json -Format json<br>                    &#39;&#39;&#39;<br>                }<br>            }<br>        }<br>    } // &lt;-- close stages<br><br>    post {<br>        always {<br>            dir(&quot;${APP_DIR}&quot;) {<br>                archiveArtifacts artifacts: &#39;nikto-output/nikto-report.json&#39;, allowEmptyArchive: true<br>            }<br>        }<br><br>        success {<br>            echo &#39;✅ Build, deploy, and scan successful!&#39;<br>        }<br><br>        failure {<br>            echo &#39;❌ Build, deploy, or scan failed!&#39;<br>        }<br>    }<br>} // &lt;-- close pipeline</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BEmBELaGIbIJ0Hl1W2Wr_g.png" /><figcaption>Jenkins Dashboard</figcaption></figure><h3>Stage 2: Run Nikto as DAST</h3><h4><strong>Dynamic Application Security Testing (DAST) with Nikto</strong></h4><p>After the deployment phase is verified, Nikto is used to perform Dynamic Application Security Testing (DAST) against the live application. As an open-source web server scanner, Nikto is designed to identify potential security vulnerabilities by actively probing the deployed environment. This includes detecting outdated software versions, misconfigurations, insecure HTTP headers, and other known issues that may be exposed to external attackers.</p><p>Running Nikto at this stage ensures that the deployed application is evaluated from an external perspective, simulating how an attacker might interact with the system. It complements static and code-level scans by revealing runtime and configuration-based weaknesses that may not be visible during earlier stages of the pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WdFLshPe5SjZhi265XG1MQ.png" /><figcaption>Performing Nikto as DAST</figcaption></figure><p>The results generated by Nikto can be saved as artifacts in the CI/CD pipeline. These artifacts provide traceability and can later be imported into our centralized Security Control Management platform, DefectDojo. This integration enables the team to consolidate findings from both static and dynamic scans in one place, facilitating efficient tracking, prioritization, remediation, and historical versioning of security issues. By incorporating Nikto into the post-deployment phase, we enhance visibility into real-world risks and strengthen the overall security posture of the application.</p><h3>Benefits and Best Practices</h3><h3>Security Coverage</h3><ul><li><strong>Multiple SAST Tools</strong>: Different tools catch different types of vulnerabilities</li><li><strong>Secret Detection</strong>: Multiple layers of secret scanning prevent credential leaks</li><li><strong>Runtime Testing</strong>: Nikto provides dynamic analysis of the running application</li><li><strong>Centralized Management</strong>: DefectDojo integration provides unified vulnerability management</li></ul><h3>Pipeline Optimization</h3><ul><li><strong>Parallel Execution</strong>: Security scans run simultaneously to reduce pipeline time</li><li><strong>Failure Handling</strong>: allow_failure: true ensures pipeline continues even if scans find issues</li><li><strong>Artifact Management</strong>: Results are preserved and accessible for analysis</li><li><strong>Integration Points</strong>: Clear handoff between GitLab and Jenkins pipelines</li></ul><h3>Monitoring and Verification</h3><ul><li><strong>Build Verification</strong>: Automatic verification of Jenkins build completion</li><li><strong>Health Checks</strong>: Container health monitoring ensures successful deployments</li><li><strong>Comprehensive Logging</strong>: Debug stages provide visibility into pipeline execution</li></ul><h3>Troubleshooting Common Issues</h3><h3>GitLab Pipeline Issues</h3><ol><li><strong>Tool Installation Failures</strong>: Use specific image versions to ensure consistency</li><li><strong>Artifact Not Found</strong>: Check dependencies between stages</li><li><strong>API Integration Failures</strong>: Verify tokens and endpoint URLs</li></ol><h3>Jenkins Pipeline Issues</h3><ol><li><strong>Container Build Failures</strong>: Check Dockerfile and build context</li><li><strong>Port Conflicts</strong>: Ensure ports are available and properly mapped</li><li><strong>Health Check Failures</strong>: Verify application startup time and health endpoints</li></ol><h3>Conclusion</h3><p>This comprehensive SAST implementation demonstrates how to integrate multiple security tools into a modern CI/CD pipeline. By combining GitLab CI/CD for static analysis with Jenkins for dynamic testing, we achieve thorough security coverage throughout the development lifecycle.</p><p>Key takeaways:</p><ul><li>Multiple SAST tools provide comprehensive coverage</li><li>Integration with security management platforms enables tracking and remediation</li><li>Containerized deployments allow for realistic security testing</li><li>Proper error handling and monitoring ensure pipeline reliability</li></ul><p>This approach scales well for enterprise environments and can be adapted for different technology stacks and security requirements.</p><h3>Next Steps</h3><p>Consider extending this implementation with:</p><ul><li>Container vulnerability scanning (Trivy, Clair)</li><li>Infrastructure as Code security scanning (Checkov, Terrascan)</li><li>API security testing (OWASP ZAP)</li><li>Compliance reporting and metrics collection</li></ul><p>The foundation provided here supports these additional security measures while maintaining pipeline performance and developer experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1b7629b3c80" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enhancing Security in Kong Gateway with Ease]]></title>
            <link>https://alandrma.medium.com/enhancing-security-in-kong-gateway-with-ease-9efaa772d3bc?source=rss-f1984a0833fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/9efaa772d3bc</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[kong-gateway]]></category>
            <category><![CDATA[security-services]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Alan Darma Saputra]]></dc:creator>
            <pubDate>Wed, 26 Feb 2025 10:47:59 GMT</pubDate>
            <atom:updated>2025-02-26T10:47:59.799Z</atom:updated>
            <content:encoded><![CDATA[<h3>Enhancing Security in Kong Gateway with Ease</h3><p>Deploying Kong Gateway is just the first step in building a secure API infrastructure. To fully safeguard APIs from cyber threats, additional security configurations are necessary. Kong Gateway provides powerful security mechanisms that help mitigate risks such as unauthorized access, abuse, and data exposure. By enabling these security features, organizations can ensure a robust API protection strategy that enhances compliance and resilience against cyber threats.</p><p>This article explores key security mechanisms, including Rate Limiting, Key Authentication, CORS, Basic Authentication, OAuth 2.0, and JWT, to help you fortify your Kong Gateway security with ease. Understanding these mechanisms will allow you to build a resilient API infrastructure capable of withstanding modern security threats.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/0*CW2xm65F2QZ3khUB.png" /><figcaption>Enhancing Security in Kong Gateway</figcaption></figure><h3>Setting Up Kong Gateway with Docker</h3><p>Kong Gateway is a powerful API gateway designed for performance and extensibility. This guide provides a quick way to get Kong Gateway running using a Docker-based script.</p><h3>Running Kong Gateway</h3><p>To quickly deploy Kong Gateway along with its supporting database, you can use the provided quickstart script. This script will set up and configure Kong Gateway along with a PostgreSQL database as the backend.</p><h3>Step 1: Execute the Quickstart Script</h3><p>Run the following command to download and execute the quickstart script:</p><pre>curl -Ls https://get.konghq.com/quickstart | bash</pre><h3>Notes:</h3><ul><li>The script runs <strong>Kong Gateway Enterprise in Free mode</strong> by default.</li><li>If you want to run Kong with a <strong>license</strong>, pass the license via an environment variable.</li><li>For additional options and advanced configurations, use the -h flag:</li></ul><pre>curl -Ls https://get.konghq.com/quickstart | bash -s -- -h</pre><h3>Step 2: Verify Kong Gateway is Running</h3><p>Once Kong Gateway is up and running, you can check its status by querying the Admin API.</p><p>Run the following command to fetch only the headers:</p><pre>curl --head localhost:8001</pre><p>If Kong Gateway is running correctly, you should receive a response similar to:</p><pre>HTTP/1.1 200 OK<br>Date: Mon, 22 Aug 2022 19:25:49 GMT<br>Content-Type: application/json<br>Connection: keep-alive<br>Access-Control-Allow-Origin: *<br>Content-Length: 11063<br>X-Kong-Admin-Latency: 6<br>Server: kong/3.9.0</pre><h3>Step 3: Evaluate Kong Gateway Configuration</h3><p>To retrieve the complete configuration of your Kong Gateway instance, use the following command:</p><pre>curl -s localhost:8001 | jq &#39;.configuration&#39;</pre><p>This will return a large JSON response containing detailed information about Kong Gateway, including networking, security settings, and available plugins.</p><h3>Step 4: Access Kong Manager</h3><p>In addition to configuring Kong Gateway via the Admin API, you can also use <strong>Kong Manager</strong>, a web-based interface that allows you to manage services, routes, plugins, and more.</p><p>To access Kong Manager, navigate to:</p><p><a href="http://localhost:8002/">http://localhost:8002</a></p><h3>Next Steps</h3><p>After completing the above steps, you can start creating <strong>services</strong> and <strong>routes</strong> by following the documentation available online. Once your API gateway is properly set up, you can begin <strong>tuning security settings</strong> for Kong Gateway to enhance its protection and performance.</p><h3>Rate Limiting</h3><h4>Enabling Rate Limiting</h4><p>The <strong>Rate Limiting</strong> plugin is installed by default on Kong Gateway and can be enabled by sending a POST request to the Admin API:</p><pre>curl -i -X POST http://localhost:8001/plugins \<br>  --data name=rate-limiting \<br>  --data config.minute=5 \<br>  --data config.policy=local</pre><p>This command configures Kong Gateway to enforce a maximum of <strong>5 requests per minute per client IP address</strong> for all routes and services.</p><h4>Policy Configuration</h4><p>The policy configuration determines how Kong Gateway tracks and increments limits. Refer to the plugin configuration reference for further details.</p><h4>Example Response</h4><p>Upon successful configuration, the response will include the new plugin details, such as:</p><pre>{<br>  &quot;id&quot;: &quot;fc559a2d-ac80-4be8-8e43-cb705524be7f&quot;,<br>  &quot;name&quot;: &quot;rate-limiting&quot;,<br>  &quot;enabled&quot;: true<br>}</pre><h4>Validating Rate Limiting</h4><p>After enabling rate limiting, you can verify its functionality by exceeding the allowed request limit within the configured time period.</p><h4>Using the Command Line</h4><p>To send <strong>6 mock requests</strong> quickly:</p><pre>for _ in {1..6}; do curl -s -i localhost:8000/mock/anything; echo; sleep 1; done</pre><p>After the 6th request, you should receive a <strong>429 API rate limit exceeded</strong> error:</p><pre>{<br>   &quot;message&quot;: &quot;API rate limit exceeded&quot;<br>}</pre><h4>Service-Level Rate Limiting</h4><p>The <strong>Rate Limiting</strong> plugin can also be applied at the <strong>service level</strong> rather than globally. To enable it for a specific service, use the following request:</p><pre>curl -X POST http://localhost:8001/services/example_service/plugins \<br>   --data &quot;name=rate-limiting&quot; \<br>   --data config.minute=5 \<br>   --data config.policy=local</pre><p>This ensures that rate limiting is applied only to the specified service, providing more granular control over API traffic management.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aiWHZUOuJCauveVuj5SwMA.png" /><figcaption>Rate Limiting Works</figcaption></figure><h3>Key Authentication</h3><h4>Overview</h4><p>Enabling <strong>global key authentication</strong> ensures that every proxy request passing through Kong Gateway is protected by API key authentication, adding an additional security layer.</p><h4>Enabling Key Authentication</h4><p>The <strong>Key Authentication</strong> plugin is installed by default on Kong Gateway and can be enabled by sending a POST request to the Admin API:</p><pre>curl -X POST http://localhost:8001/plugins/ \<br>    --data &quot;name=key-auth&quot;  \<br>    --data &quot;config.key_names=apikey&quot;</pre><p>Upon success, you will receive a <strong>201 Created</strong> response, indicating the plugin has been installed.</p><h4>Key Configuration</h4><p>The key_names field defines the name of the field the plugin will look for when authenticating requests. By default, the plugin checks for the API key in:</p><ul><li><strong>Headers</strong></li><li><strong>Query string parameters</strong></li><li><strong>Request body</strong></li></ul><h4>Validating Key Authentication</h4><h4>Sending an Unauthenticated Request</h4><p>Attempt to access a service without providing an API key:</p><pre>curl -i http://localhost:8000/mock/anything</pre><p>Since key authentication is enforced globally, you will receive a <strong>401 Unauthorized</strong> response:</p><pre>{<br>    &quot;message&quot;: &quot;No API key found in request&quot;<br>}</pre><h4>Sending an Incorrect Key</h4><p>Try accessing the service with an invalid API key:</p><pre>curl -i http://localhost:8000/mock/anything \<br>  -H &#39;apikey:bad-key&#39;</pre><p>You will receive another <strong>401 Unauthorized</strong> response:</p><pre>{<br>  &quot;message&quot;: &quot;Invalid authentication credentials&quot;<br>}</pre><h4>Sending a Valid Request</h4><p>To successfully authenticate, include a valid API key in the request header:</p><pre>curl -i http://localhost:8000/mock/anything \<br>  -H &#39;apikey:top-secret-key&#39;</pre><p>If the key is correct, you will receive a <strong>200 OK</strong> response.</p><h4>Service-Based Key Authentication</h4><p>Instead of enabling key authentication globally, you can apply it to specific services. To enable key authentication for a specific service, send the following request:</p><pre>curl -X POST http://localhost:8001/services/example_service/plugins \<br>     --data name=key-auth</pre><p>This ensures that API key authentication is required only for the specified service, providing more granular access control.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*3yHVGJFr93Pyvyw9lhfQHg.png" /></figure><h3>CORS (Cross-Origin Resource Sharing)</h3><h4>Overview</h4><p>Cross-Origin Resource Sharing (<strong>CORS</strong>) is a security feature that allows or restricts web applications from making requests to a different domain than the one serving the application. Enabling <strong>CORS</strong> in Kong Gateway helps ensure controlled access to your APIs from external domains.</p><h4>Enabling CORS Globally</h4><p>The <strong>CORS Plugin</strong> is installed by default on Kong Gateway and can be enabled globally by sending a POST request to the Admin API:</p><pre>curl -X POST http://localhost:8001/plugins/ \<br>    --data &quot;name=cors&quot; \<br>    --data &quot;config.origins=*&quot; \<br>    --data &quot;config.methods=GET,POST,PUT,DELETE&quot; \<br>    --data &quot;config.headers=Accept,Authorization,Content-Type&quot; \<br>    --data &quot;config.credentials=true&quot;</pre><h4>Explanation of Configuration:</h4><ul><li>config.origins=* → Allows requests from any origin (*).</li><li>config.methods=GET,POST,PUT,DELETE → Specifies allowed HTTP methods.</li><li>config.headers=Accept,Authorization,Content-Type → Defines which headers are permitted in requests.</li><li>config.credentials=true → Allows sending credentials (e.g., cookies, authentication tokens).</li></ul><p>Upon success, you will receive a <strong>201 Created</strong> response, indicating the plugin has been installed.</p><h4>Validating CORS Configuration</h4><h4>Sending a Preflight Request</h4><p>To test if <strong>CORS</strong> is enabled, send an <strong>OPTIONS</strong> request:</p><pre>curl -i -X OPTIONS http://localhost:8000/mock/anything \<br>  -H &quot;Origin: https://example.com&quot; \<br>  -H &quot;Access-Control-Request-Method: GET&quot;</pre><p>If <strong>CORS</strong> is correctly configured, the response should include the allowed methods and headers:</p><pre>HTTP/1.1 204 No Content<br>Access-Control-Allow-Origin: *<br>Access-Control-Allow-Methods: GET,POST,PUT,DELETE<br>Access-Control-Allow-Headers: Accept,Authorization,Content-Type<br>Access-Control-Allow-Credentials: true</pre><h4>Enabling CORS for a Specific Service</h4><p>To enable <strong>CORS</strong> for a specific service instead of globally, send the request to the service URL:</p><pre>curl -X POST http://localhost:8001/services/example_service/plugins \<br>    --data &quot;name=cors&quot; \<br>    --data &quot;config.origins=*&quot; \<br>    --data &quot;config.methods=GET,POST,PUT,DELETE&quot; \<br>    --data &quot;config.headers=Accept,Authorization,Content-Type&quot; \<br>    --data &quot;config.credentials=true&quot;</pre><p>This ensures <strong>CORS</strong> is enabled only for the specified service, providing more granular control.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1nLgL-qraz7E4lzGANSjkw.png" /><figcaption>Web GUI Enable CORS</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o4fDJKPa6qU2fVGeMNEv6w.png" /><figcaption>Advance Parameters CORS</figcaption></figure><p>Here are some key benefits of using <strong>CORS (Cross-Origin Resource Sharing)</strong> in <strong>Kong Gateway</strong>:</p><h4>1. Allows Access from Multiple Domains</h4><ul><li><strong>CORS</strong> enables APIs to be accessed from multiple allowed domains instead of restricting requests to a single source.</li><li>This is useful for frontend applications running on a different domain from the backend.</li></ul><h4>2. Enhanced Security Control</h4><ul><li><strong>CORS</strong> allows fine-grained control over security policies, such as specifying allowed <strong>origins</strong>, permitted HTTP methods, and accepted headers.</li><li>It prevents unauthorized cross-origin requests while ensuring legitimate access.</li></ul><h4>3. Supports Modern Web Applications</h4><ul><li>Many modern web applications, including <strong>Single Page Applications (SPAs)</strong>, <strong>Progressive Web Apps (PWAs)</strong>, and <strong>microservices-based architectures</strong>, require cross-origin communication.</li><li><strong>CORS</strong> ensures these applications function correctly without unnecessary restrictions.</li></ul><h4>4. Prevents Unauthorized Data Access</h4><ul><li>Without <strong>CORS</strong>, browsers block cross-origin requests by default, which could disrupt legitimate integrations.</li><li>Configuring <strong>CORS</strong> properly prevents unauthorized access while allowing secure data exchange.</li></ul><h4>5. Improves API Usability and Adoption</h4><ul><li>By enabling <strong>CORS</strong>, APIs become more flexible and accessible to third-party developers and integrations.</li><li>This can help increase API adoption without compromising security.</li></ul><p>Securing <strong>Kong Gateway</strong> is essential to ensuring the protection of APIs and sensitive data from potential threats. By implementing robust security measures such as <strong>rate limiting, key authentication, CORS, and other security plugins</strong>, you can effectively safeguard your API infrastructure while maintaining performance and accessibility.</p><p>As security threats continue to evolve, it is crucial to <strong>continuously monitor, fine-tune configurations, and stay updated with best practices</strong> to keep your Kong Gateway deployment resilient. With a well-secured API gateway, organizations can confidently provide seamless and secure API access while mitigating risks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9efaa772d3bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Performing Vulnerability Scans on Docker Images with Grype]]></title>
            <link>https://alandrma.medium.com/performing-vulnerability-scans-on-docker-images-with-grype-8d7ffe94b1fa?source=rss-f1984a0833fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d7ffe94b1fa</guid>
            <category><![CDATA[vulnerability-scanning]]></category>
            <category><![CDATA[docker-image]]></category>
            <category><![CDATA[grype]]></category>
            <dc:creator><![CDATA[Alan Darma Saputra]]></dc:creator>
            <pubDate>Tue, 20 Aug 2024 07:02:45 GMT</pubDate>
            <atom:updated>2024-08-20T07:02:45.586Z</atom:updated>
            <content:encoded><![CDATA[<p>In our continuous efforts to maintain a secure and robust container environment, we recently conducted a vulnerability scan on our Docker images using Grype, a powerful tool by Anchore. This process is critical as it helps us identify and mitigate potential security risks that could compromise our applications.</p><p><strong>Why Grype?</strong></p><p>Grype stands out for its simplicity and effectiveness. It’s an open-source vulnerability scanner that integrates seamlessly with Docker, allowing us to scan images for known vulnerabilities in the OS packages and language-specific dependencies. Grype provides comprehensive and up-to-date vulnerability data, which is crucial for staying ahead of potential threats.</p><h3>Features</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vu0r2FlpUFajJqcNybmOwg.png" /><figcaption>Features Grype</figcaption></figure><p><strong>The Scanning Process</strong></p><p>The scanning process was straightforward. We used the Grype CLI to scan our Docker images directly. The tool analyzed the contents of each image, checking for vulnerabilities across various layers, including the base image, application dependencies, and even custom layers we’ve added.</p><p>Here’s a quick overview of how we performed the scan:</p><p><strong>Installation</strong>: We started by installing Grype, which was as simple as running a command to download the binary.</p><blockquote>curl -sSfL <a href="https://raw.githubusercontent.com/anchore/grype/main/install.sh">https://raw.githubusercontent.com/anchore/grype/main/install.sh</a> | sh -s — -b /usr/local/bin</blockquote><p><strong>Scanning</strong>: We executed the scan by pointing Grype to the Docker image we wanted to analyze. The command is as simple as:</p><blockquote>grype &lt;image&gt;</blockquote><p><strong>Reviewing Results</strong>: Once the scan was complete, we carefully reviewed the results. Grype’s output provided not just the list of vulnerabilities but also details on their impact and possible fixes. This allowed us to prioritize the remediation process based on the severity and relevance of each vulnerability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wq2flKv2a3S3gLwzOTxevw.png" /><figcaption>The vulnerabilities listed on the official Docker Hub website.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EhCm0r489AkHhvS4cahybQ.png" /><figcaption>The vulnerabilities found in the results of the Grype scan.</figcaption></figure><p>In the results above, there is a close match between the scan results and what is listed on their official website. This indicates that the Grype scanner provides highly accurate vulnerability data, aligning well with the official information provided by Docker Hub.</p><p><strong>Actionable Insights</strong>: After identifying the vulnerabilities, we took the necessary steps to mitigate them. This often involved updating base images, applying security patches, or replacing vulnerable libraries with more secure alternatives.</p><p><strong>Conclusion</strong></p><p>Using Grype for vulnerability scanning has become an integral part of our DevSecOps pipeline. It ensures that our Docker images are not only functional but also secure. In a world where container security is paramount, tools like Grype help us maintain a strong security posture by proactively identifying and addressing vulnerabilities before they can be exploited.</p><p><strong>Grype Databases</strong></p><blockquote><a href="https://github.com/anchore/grype?tab=readme-ov-file#grypes-database">https://github.com/anchore/grype?tab=readme-ov-file#grypes-database</a></blockquote><p><strong><em>For Futher Information</em></strong></p><blockquote><a href="https://github.com/anchore/grype?tab=readme-ov-file#grypes-database">https://github.com/anchore/grype</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d7ffe94b1fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Deploy DVWA with Docker]]></title>
            <link>https://alandrma.medium.com/how-to-deploy-dvwa-with-docker-b918a1829930?source=rss-f1984a0833fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/b918a1829930</guid>
            <dc:creator><![CDATA[Alan Darma Saputra]]></dc:creator>
            <pubDate>Tue, 24 Oct 2023 17:56:09 GMT</pubDate>
            <atom:updated>2023-10-24T18:00:29.047Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello world,</p><p>On this occasion, I would like to share the process of deploying DVWA as a means to train capabilities in cyber attacks.</p><p>Since I first got involved in the world of technology, I have been fascinated by the complexity and dynamics of the cyber world. My passion to understand and protect the digital world has taken me on countless journeys in the world of cyber security.</p><p>In addition to my experience in the world of work, I also want to actively contribute to cyber security little by little. I also try to write cyber security articles and tutorials which I share online to help individuals understand and overcome digital security threats.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*08TlxKBqIQl90bRT0MITog.png" /></figure><p>In the realm of web security and penetration testing, deploying the Damn Vulnerable Web Application, or DVWA, within a Docker container is a strategic move. Docker, the containerization technology that has revolutionized software deployment, now provides us with a streamlined means of hosting DVWA in a secure, isolated environment. Let’s embark on a journey to understand how to set up and deploy DVWA in Docker, taking advantage of its flexibility, reproducibility, and portability.</p><p>First, we start by pulling the DVWA Docker image from a trusted repository. This image is pre-configured with DVWA, a vulnerable web application designed to help security professionals and enthusiasts learn and practice web security in a controlled and safe environment. Pulling the image is as simple as a single Docker command, making it easy for anyone to get started.</p><pre>docker pull vulnerables/web-dvwa</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TeH63BLDjLPqBY8WxM5r8Q.png" /></figure><p>Once the DVWA Docker image is successfully pulled, we can create a Docker container from it. This container is an isolated instance of the application, which means it won’t interfere with any other services or applications running on your system. You can define port mappings, ensuring you can access the DVWA web interface from your host machine.</p><p>To run this image you need <a href="http://docker.com/">docker</a> installed. Just run the command:</p><pre>docker run --rm -it -p 80:80 vulnerables/web-dvwa</pre><blockquote>Make sure your port 80 is open and not used in other services, You can add -d to start a Docker container in detached mode</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*is-jhL5Z81AMhIp9m_uoiQ.png" /></figure><p>With the container up and running, you can access the DVWA web interface through a web browser. Here, you’ll find a range of security challenges and vulnerabilities intentionally built into the application. These vulnerabilities, such as SQL injection, cross-site scripting, and more, provide a safe environment to practice identifying and mitigating security threats.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JwUlSqnD9gTGgxF646CxNA.png" /></figure><p>Just click on the Create / Reset database button and it will generate any aditional configuration needed.</p><h4>Login with default credentials</h4><p>To login you can use the following credentials:</p><ul><li>Username: admin</li><li>Password: password</li></ul><h4>Set the dificulty level</h4><p>The default dificulty level is the impossible level, you can change it in DVWA Security item in the left menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yzxNEnm6w-GYYUJjJvYR5g.png" /></figure><h4>Hack and have fun !</h4><p>If you are playing it in low dificulty, just to have a taste of how exploit a flaw in this app, go to SQL Injection in the left menu. In the id field, add this query:</p><pre>1&#39; union select 1,2-- -</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rn8QRW7RZImG8QQXshX3hA.png" /></figure><p>What makes this approach so powerful is the ability to create multiple instances of DVWA in isolated containers. This allows you to simulate various web application environments, test different attack scenarios, and sharpen your web security skills in a controlled manner. Furthermore, if you encounter any issues or want to reset the application to its initial state, you can easily do so without affecting your host system.</p><p>In conclusion, deploying DVWA in Docker brings together the best of both worlds: a purpose-built vulnerable web application and the power of containerization. It’s a valuable tool for those looking to explore, understand, and strengthen their web security expertise. By encapsulating DVWA in a Docker container, you can securely hone your skills and become a more proficient web security practitioner, all while keeping the broader digital landscape safe from unintended consequences. So, let’s dive in and get started with DVWA in Docker — the cyber training ground that’s both instructive and secure.</p><h3>About DVWA</h3><p>You can visit DVWA <a href="http://www.dvwa.co.uk/">official website</a> and official <a href="https://github.com/ethicalhack3r/DVWA">github repository</a> if you want more information.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b918a1829930" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lorem Ipsum]]></title>
            <link>https://alandrma.medium.com/lorem-ipsum-57445ca1d55c?source=rss-f1984a0833fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/57445ca1d55c</guid>
            <dc:creator><![CDATA[Alan Darma Saputra]]></dc:creator>
            <pubDate>Wed, 04 Oct 2023 08:48:53 GMT</pubDate>
            <atom:updated>2023-10-04T08:50:56.647Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VwUJZIwMbTztHynFTChYQA.jpeg" /></figure><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut porta velit a purus eleifend, in vulputate purus auctor. Etiam tristique orci eu nisl molestie, at mollis odio feugiat. Mauris facilisis egestas mattis. Nulla pulvinar porta porttitor. Quisque sodales luctus est vel molestie. Fusce rutrum tristique ipsum, non faucibus massa lacinia ut. Pellentesque sit amet malesuada augue, ac laoreet nisi. Nam placerat enim ut lacinia tempor. Morbi lectus purus, condimentum dapibus ex vitae, euismod imperdiet turpis. Donec imperdiet eget lorem nec gravida. Ut auctor nisi id magna consectetur, id aliquet ex semper.</p><p>Quisque fermentum ante et libero ultricies, vitae ultricies eros porttitor. Etiam posuere molestie pulvinar. Suspendisse ut justo vel tellus sagittis gravida sit amet feugiat orci. Etiam consequat quis massa quis rhoncus. Proin leo quam, dignissim a pellentesque vel, mollis ac justo. Nunc urna nulla, egestas non vestibulum nec, consectetur in augue. Phasellus sit amet scelerisque neque. Proin quis sollicitudin libero.</p><p>Donec non velit sit amet turpis accumsan tempus. Praesent interdum mauris quis nisl lacinia, congue pellentesque neque pellentesque. Suspendisse convallis pharetra est, vitae vulputate justo facilisis in. Aenean aliquam quam sodales nulla viverra, vitae pharetra elit pulvinar. Donec vel enim quis arcu tincidunt laoreet. Nullam quis magna sapien. Curabitur non feugiat nisi. Nunc ornare, eros vel consectetur efficitur, velit libero auctor ex, a lobortis magna felis sed nibh. Nunc pharetra eros ex, nec volutpat massa commodo eget.</p><p>Praesent pellentesque enim vitae mauris congue, eget sodales neque vestibulum. Mauris egestas urna neque, nec placerat tellus consectetur at. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed eu ante tristique, pellentesque purus vitae, luctus turpis. Aenean imperdiet nisi et viverra semper. Interdum et malesuada fames ac ante ipsum primis in faucibus. Suspendisse dui est, consequat scelerisque faucibus eget, malesuada vel diam.</p><p>Morbi commodo porttitor enim, eget hendrerit elit auctor sit amet. Vivamus sem ipsum, vulputate in condimentum vel, ullamcorper a dolor. Mauris dignissim diam arcu, eget mattis odio gravida eu. Curabitur tincidunt mauris arcu, quis sollicitudin felis vestibulum sit amet. Curabitur fringilla massa metus, ut maximus nisi fringilla ac. Morbi iaculis luctus posuere. Integer id tristique est. Integer porta facilisis tristique. Sed eget mi vitae erat convallis molestie eu in nisl. Nunc rhoncus faucibus sapien, non finibus mi fermentum et.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57445ca1d55c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>