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.
Download this n8n workflow template and start using it instantly.
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.
This automation begins with the user providing a target URL through the n8n trigger node.
Landing Page Url1 form n8n trigger collects the URL of the website to be audited.Puppeteer1 n8n node navigates to the provided URL, waiting for the network to be idle to ensure all dynamic scripts are loaded.JavaScript Extractor1 n8n node (a Code node) uses regular expressions to parse the resulting HTML and isolate the URLs of all linked JavaScript files.Aggregate1 n8n node combines all extracted JavaScript URLs into a single data item, preparing it for AI processing.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.Format Report for Email1 Code n8n node wraps the plain text AI output into a cleaner HTML structure.Send a message1 Gmail n8n node delivers the full HTML security report to the designated recipient, completing the n8n workflow.To utilize this n8n workflow template, follow these steps:
n8n-nodes-puppeteer.OpenAI Chat Model n8n node. You will need an API key for access.Send a message1 Gmail n8n node (preferably using OAuth2 for security). Update the sendTo parameter to your target email address.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. 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 (/