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

# Analyze JavaScript Code

> Identify vulnerabilities, collect useful data, and prepare JavaScript code for manual review

export const ModuleOverview = ({category, inputs, outputs, author, createdDate, iframeUrl, long_description}) => <div style={{
  backgroundColor: 'var(--background-card)',
  borderRadius: '16px',
  padding: '32px',
  boxShadow: '0 8px 32px rgba(0, 0, 0, 0.08)'
}}>
    <div style={{
  width: '100%',
  height: '600px',
  backgroundColor: 'var(--background-default)',
  borderRadius: '16px',
  overflow: 'hidden',
  border: '1px solid var(--border-default)',
  marginBottom: '24px',
  position: 'relative'
}}>
      <div style={{
  width: '100%',
  height: '100%'
}}>
        <div className="p-2 not-prose relative bg-gray-50/50 rounded-xl overflow-hidden dark:bg-gray-800/25" style={{
  width: '100%',
  height: '100%'
}}>
          <div className="absolute inset-0 bg-grid-neutral-200/20 [mask-image:linear-gradient(0deg,#fff,rgba(255,255,255,0.6))] dark:bg-grid-white/5 dark:[mask-image:linear-gradient(0deg,rgba(255,255,255,0.1),rgba(255,255,255,0.5))]" style={{
  backgroundPosition: '10px 10px'
}}></div>
          <div className="relative rounded-lg overflow-hidden flex justify-center" style={{
  width: '100%',
  height: '100%'
}}>
            <iframe src={iframeUrl} scrolling="no" style={{
  position: 'absolute',
  top: 0,
  left: 0,
  width: '100%',
  height: '100%',
  border: 'none',
  overflow: 'hidden'
}} title="Module Preview" />
          </div>
          <div className="absolute inset-0 pointer-events-none border border-black/5 rounded-xl dark:border-white/5"></div>
        </div>
      </div>
    </div>

    <div style={{
  display: 'flex',
  justifyContent: 'space-between',
  alignItems: 'center',
  marginBottom: '24px'
}}>
      <div style={{
  display: 'flex',
  gap: '16px',
  alignItems: 'center'
}}>
        <span style={{
  background: 'linear-gradient(135deg, #00a3ff, #0065ff)',
  color: 'white',
  padding: '8px 16px',
  borderRadius: '24px',
  fontSize: '0.875rem',
  fontWeight: '600',
  textTransform: 'uppercase'
}}>
          {category}
        </span>
      </div>
      
      <div style={{
  display: 'flex',
  gap: '24px',
  alignItems: 'center'
}}>
        <div>
          <p style={{
  color: 'var(--text-secondary)',
  fontSize: '0.875rem',
  margin: 0
}}>Created by</p>
          <p style={{
  color: 'var(--text-primary)',
  fontWeight: '500',
  margin: 0
}}>{author}</p>
        </div>
        <div style={{
  width: '1px',
  height: '32px',
  backgroundColor: 'var(--border-default)'
}} />
        <div>
          <p style={{
  color: 'var(--text-secondary)',
  fontSize: '0.875rem',
  margin: 0
}}>Last updated</p>
          <p style={{
  color: 'var(--text-primary)',
  fontWeight: '500',
  margin: 0
}}>
            {new Date(createdDate).toLocaleDateString()}
          </p>
        </div>
      </div>
    </div>

    <p style={{
  color: 'rgba(163, 179, 188, 0.8)',
  fontSize: '1rem',
  margin: '0 0 24px 0',
  lineHeight: '1.6'
}}>
      {long_description}
    </p>

    <div style={{
  display: 'grid',
  gridTemplateColumns: '1fr 1fr',
  gap: '32px'
}}>
      <div>
        <h3 style={{
  fontSize: '1.25rem',
  fontWeight: '600',
  color: 'var(--text-primary)',
  marginBottom: '16px',
  display: 'flex',
  alignItems: 'center',
  gap: '8px'
}}>
          <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor">
            <path d="M5 12h14M12 5l7 7-7 7" />
          </svg>
          Input Parameters
        </h3>
        <div style={{
  display: 'flex',
  flexDirection: 'column',
  gap: '12px'
}}>
          {Object.entries(inputs).map(([key, value]) => <div key={key} style={{
  padding: '16px',
  backgroundColor: 'var(--background-default)',
  borderRadius: '12px',
  border: '1px solid var(--border-default)'
}}>
              <ParamField query={key} type={value.type.toLowerCase()} optional={!value.visible} required={value.visible}>
                <span style={{
  fontSize: '0.95rem',
  color: 'var(--text-secondary)',
  lineHeight: '1.5'
}}>
                  {value.description}
                </span>
              </ParamField>
            </div>)}
        </div>
      </div>

      <div>
        <h3 style={{
  fontSize: '1.25rem',
  fontWeight: '600',
  color: 'var(--text-primary)',
  marginBottom: '16px',
  display: 'flex',
  alignItems: 'center',
  gap: '8px'
}}>
          <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor">
            <circle cx="12" cy="12" r="10" /><path d="M8 12h8" />
          </svg>
          Outputs
        </h3>
        <div style={{
  display: 'flex',
  flexWrap: 'wrap',
  gap: '6px'
}}>
          {outputs.map((output, index) => <span key={index} style={{
  background: 'rgba(255, 107, 0, 0.1)',
  borderRadius: '6px',
  padding: '2px 8px',
  fontSize: '0.7rem',
  display: 'inline-flex',
  alignItems: 'center',
  gap: '4px',
  color: '#ff6b00',
  border: '1px solid rgba(255, 107, 0, 0.2)'
}}>
              {output}
            </span>)}
        </div>
      </div>
    </div>
  </div>;

<ModuleOverview
  category="Vulnerability Scanning"
  inputs={ {
"urls": {
"name": "urls",
"type": "FILE",
"visible": true,
"description": "List of script URLs",
},
"header": {
"name": "header",
"type": "STRING",
"visible": false,
"description": "Header(s) to include in HTTP requests",
},
"in-scope": {
"name": "in-scope",
"type": "FILE",
"visible": false,
"description": "List of URLs, paths, or regular expressions used to identify endpoints for extraction",
},
"out-of-scope": {
"name": "out-of-scope",
"type": "FILE",
"visible": false,
"description": "List of URLs, paths, or regular expressions to ignore during endpoint extraction",
},
}}
  outputs={[ 
"endpoints",
"code",
"path-wordlist",
"parameter-wordlist",
"findings"
]}
  author="mhmdiaa-trickest"
  createdDate="2024-11-07"
  iframeUrl="https://editor.trickest.io/preview?workflow_url=https://trickest-public-workflow.s3.eu-central-1.amazonaws.com/59d27322-f3b7-49ef-b9bc-874fe19e2c52.json"
/>

# Analyze JavaScript Code

## Description

Retrieve JavaScript code from a list of URLs while preserving its original location structure. When available, extract sourcemaps to obtain non-minified code, then beautify and deobfuscate all code. Analyze the code to discover hidden endpoints, generate custom path and parameter brute-force wordlists based on script content, and scan for vulnerabilities by identifying outdated dependencies, insecure code patterns, and exposed secrets.

## Features

* **Prepares code for manual review** by downloading all files to a single location, extracting sourcemaps when available to obtain original, non-minified code.
* Simplifies code review by **beautifying and deobfuscating code**, and applying transformations such as unpacking arrays and removing redundant proxy functions.
* Extracts **hidden endpoints** and paths from the code, including parameters and request methods.
* Generates a **custom wordlist for path discovery** based on identified endpoints.
* Creates a **custom wordlist for parameter discovery** using found endpoints and variable names.
* Checks for **outdated dependencies** and identifies associated CVEs when available.
* Scans for a wide range of **exposed secrets**.
* Analyzes code for **insecure patterns and client-side vulnerabilities**.

## Inputs

### Required

* **urls:** List of JavaScript code URLs (non-JS URLs will be automatically filtered out)

```
https://example.com/script.js
https://cdn.example.com/assets/app.min.js
https://another-example.com/js/main.js
```

## Outputs

* **findings**: JSONLines records of finding details

```json theme={null}
{"finding": "Potential exposed secret: URI","location": "https://cdn.example.com/assets/app.min.js","severity": "unknown","hostname": "cdn.example.com","domain_name": "example.com","method": "GET","matches": ["http://admin:password@example.com"]}
{"finding": "Outdated JavaScript component: jquery 2.2.3","location": "https://example.com/script.js","severity": "medium","hostname": "example.com","domain_name": "example.com","method": "GET","matches": ["CVE-2015-9251","CVE-2019-11358","CVE-2020-11023","CVE-2020-11022"]}
{"finding": "DOM Based XSS","location": "https://another-example.com/js/main.js","severity": "medium","description": "Detected possible DOM-based XSS. This occurs because a portion of the URL is being used to construct an element added directly to the page. For example, a malicious actor could send someone a link like this: http://www.some.site/page.html?default=<script>alert(document.cookie)</script> which would add the script to the page. Consider allowlisting appropriate values or using an approach which does not involve the URL.","hostname": "another-example.com","domain_name": "another-example.com","method": "GET","matches": ["line 27"]}
```

* **endpoints**: JSONLines records of endpoint details, including parameters and request methods

```json theme={null}
{"url": "/api/login", "query_parameter": "", "body_parameter": "username", "method": "POST", "source_files": ["https://another-example.com/js/main.js"]}
{"url": "/api/login", "query_parameter": "", "body_parameter": "password", "method": "POST", "source_files": ["https://another-example.com/js/main.js"]}
{"url": "/api/users", "query_parameter": "id", "body_parameter": "", "method": "GET", "source_files": ["https://another-example.com/js/main.js"]}
{"url": "/Dashboard", "query_parameter": "", "body_parameter": "", "method": "", "source_files": ["https://another-example.com/js/main.js"]}
```

* **path-wordlist**: List of possible paths derived from identified endpoints

```
api/login/
api/users
Dashboard
```

* **parameter-wordlist**: List of possible parameters derived from identified endpoints and variable names within the code

```
username
password
id
url
role
```

* **code**: Folder containing the downloaded and analyzed code, with files beautified, deobfuscated, simplified, and sourcemaps resolved where available.

```
code/
├── example.com/
│   └── app.js             # Original source from resolved sourcemap
├── cdn.example.com/
│   ├── script.js          # Beautified and deobfuscated version of the original minified script
└── another-example.com/
    └── main.js
```

## Changelog

* v1.0.0
  * Initial release
* v1.0.1
  * Added `header` input
* v1.0.2
  * Improved source map handling for locations that have no corresponding content available
* v2.0.0
  * Update `endpoints` output format to be compatible with the `url-details` format
  * Add `in-scope` and `out-of-scope` inputs for filtering extracted endpoints
