Website JavaScript Security Scanner and AI Report Generator - n8n Workflow

Use this powerful n8n workflow to automatically scan a website's frontend JavaScript files for sensitive data like API keys and PII using Puppeteer and an OpenAI Agent. Get instant, actionable security reports via email. A perfect n8n template for security audits.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Cybersecurity professionals needing automated web application security scans.

  • Developers aiming to audit their production website for unintended credential exposure.

  • Anyone looking for advanced examples of using the n8n node structure combining scraping (Puppeteer) and AI (OpenAI/LangChain).

  • Users seeking an effective n8n templates solution for scheduled security monitoring.

Overview

Exposing sensitive information like API keys, hardcoded credentials, or PII within client-side JavaScript is a major security risk. This comprehensive n8n workflow solves this problem by providing a quick, automated audit. It leverages the power of Puppeteer to scrape the target site and extracts all linked JavaScript files. These files are then passed to an advanced AI agent (using the OpenAI n8n node) which acts as a cybersecurity expert. This n8n workflow not only detects issues but also generates a professional, actionable security report, which is then delivered directly to your inbox via Gmail. This end-to-end automation ensures continuous, proactive security monitoring, making this one of the most valuable n8n templates for technical users.

How it Works

This automation begins with the user providing a target URL through the n8n trigger node.


  1. Input Trigger: The Landing Page Url1 form n8n trigger collects the URL of the website to be audited.

  2. Initial Scrape: The Puppeteer1 n8n node navigates to the provided URL, waiting for the network to be idle to ensure all dynamic scripts are loaded.

  3. Extraction: The JavaScript Extractor1 n8n node (a Code node) uses regular expressions to parse the resulting HTML and isolate the URLs of all linked JavaScript files.

  4. Data Consolidation: The Aggregate1 n8n node combines all extracted JavaScript URLs into a single data item, preparing it for AI processing.

  5. AI Analysis (Core Logic): The JavaScript Search Agent w/Email Template1 (LangChain Agent) receives the list of URLs and uses the connected OpenAI Chat Model n8n node. It is expertly prompted to fetch the content of these JavaScript files, analyze them for sensitive keywords (API keys, emails, PII), and structure the findings into a professionally formatted security report email.

  6. Report Formatting: The Format Report for Email1 Code n8n node wraps the plain text AI output into a cleaner HTML structure.

  7. Notification: Finally, the Send a message1 Gmail n8n node delivers the full HTML security report to the designated recipient, completing the n8n workflow.

Installation Guide

To utilize this n8n workflow template, follow these steps:


  1. Import: Copy the provided JSON data and import it into your self-hosted or cloud n8n instance using the 'New' button and 'Import from JSON'.

  2. Dependencies: Ensure the Puppeteer community n8n node is installed. Navigate to Settings > Community Nodes and install n8n-nodes-puppeteer.

  3. OpenAI Setup: Configure credentials for the OpenAI Chat Model n8n node. You will need an API key for access.

  4. Gmail Setup: Configure credentials for the Send a message1 Gmail n8n node (preferably using OAuth2 for security). Update the sendTo parameter to your target email address.

  5. Trigger Execution: Click 'Execute workflow' and access the URL provided by the Landing Page Url1 form n8n trigger. Input the target website URL to start the security audit. This particular n8n workflow acts as an effective automated scanner.

Node Details

Landing Page Url1 (Form Trigger): This n8n trigger starts the workflow, presenting a form to the user to input the 'Landing Page Url' for the security scan. This is the entry point of the entire n8n automation.
Puppeteer1 (Puppeteer n8n node): Navigates to the user-provided URL (={{ $json['Landing Page Url'] }}) and scrapes the rendered HTML, ensuring scripts loaded dynamically are visible. Key configuration: waitUntil: 'networkidle2'.
JavaScript Extractor1 (Code n8n node): Contains custom JavaScript code using a regular expression (/]src="([^"]+)"[^>]>/g) to accurately pull out all src links for JavaScript files from the scraped HTML body.
Aggregate1 (Aggregate n8n node): Collates all individual JavaScript URL items generated by the extractor into a single list for efficient processing by the AI agent.
OpenAI Chat Model (LangChain n8n node): Provides the computational language model (GPT-4 mini specified) necessary for the advanced analysis carried out by the agent.
JavaScript Search Agent w/Email Template1 (LangChain Agent n8n node): The brain of the security audit. It utilizes a detailed system prompt defining its role as a cybersecurity expert. It analyzes the collected script URLs for sensitive data, applying complex logic to filter results and format a final report, fulfilling a critical step in this n8n workflow.
Format Report for Email1 (Code n8n node): Converts the AI agent's plain text report into basic HTML (

and
) to improve readability when received via email.
Send a message1 (Gmail n8n node): The final action, sending the security report (contained in $json.htmlReport) to the specified administrative email address.

Related n8n Workflows

Free

Nodes: 9 Nodes
Updated: December 26 2025
View all
Created by

I am seeking opportunities where I can leverage my skills and experience to contribute effectively. I thrive in environments that value adaptability, routine, and clear communication. I am excited to explore new opportunities and bring my unique perspective and determination to a forward-thinking organization.

Featured*