# Subresource Integrity Auditor (`phoenix2810/subresource-integrity-auditor`) Actor

Audit one public page for Subresource Integrity coverage on external scripts and stylesheets. Flags missing integrity, weak hashes, invalid formats, crossorigin gaps, and insecure resource URLs.

- **URL**: https://apify.com/phoenix2810/subresource-integrity-auditor.md
- **Developed by:** [Sanskar Jaiswal](https://apify.com/phoenix2810) (community)
- **Categories:** Developer tools, SEO tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Subresource Integrity Auditor

Audit one public page for Subresource Integrity coverage on external scripts and stylesheets. The actor fetches the page HTML once, extracts script and stylesheet resources, and returns SRI readiness fields suitable for QA pipelines, security checks, and scheduled monitoring.

### Use cases

- Check marketing pages before launch for third-party CDN script risk.
- Monitor CMS templates for missing SRI on scripts and stylesheets.
- Add a focused SRI gate to security and frontend QA workflows.
- Inventory third-party assets that should be pinned with integrity hashes.

### Input

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `startUrl` | string | Yes | Public page URL to audit. HTTP and HTTPS only. Private IP ranges and URL credentials are blocked. |
| `timeoutSeconds` | integer | No | Request timeout in seconds. Default: `10`. Minimum: `3`. Maximum: `30`. |
| `maxHtmlBytes` | integer | No | Maximum HTML bytes to download and parse. Default: `1048576`. Maximum: `2097152`. |

### Output

Each run pushes one dataset item.

| Field | Type | Description |
| --- | --- | --- |
| `inputUrl` | string | URL provided as input. |
| `finalUrl` | string | Final URL after redirects. |
| `status` | integer | HTTP response status, when available. |
| `https` | boolean | Whether the final page was loaded over HTTPS. |
| `truncated` | boolean | Whether HTML parsing stopped at `maxHtmlBytes`. |
| `fetchError` | string or null | Fetch or validation error, when one occurred. |
| `resourceCount` | integer | Number of scripts and stylesheets checked. |
| `thirdPartyCount` | integer | Number of checked resources on a different registrable domain. |
| `missingIntegrityCount` | integer | Third-party resources missing an `integrity` attribute. |
| `weakHashCount` | integer | Resources using only `sha256` integrity. |
| `invalidIntegrityCount` | integer | Resources with unsupported or invalid integrity token format. |
| `missingCrossoriginCount` | integer | Cross-origin resources using SRI without `crossorigin`. |
| `insecureResourceCount` | integer | Resources loaded over non-HTTPS URLs. |
| `resources` | array | Per-resource details: tag, URL, third-party flag, integrity status, algorithms, crossorigin, HTTPS, issues, and recommendation. |
| `issues` | array | Deduplicated issue list. |
| `score` | integer | SRI readiness score from 0 to 100. |
| `grade` | string | Letter grade: A+, A, B, C, D, E, or F. |
| `checkedAt` | string | ISO timestamp. |
| `recommendations` | array | Actionable remediation steps. |

### Example input

```json
{
  "startUrl": "https://example.com",
  "timeoutSeconds": 10,
  "maxHtmlBytes": 1048576
}
```

### Example output

```json
{
  "inputUrl": "https://example.com",
  "finalUrl": "https://example.com/",
  "status": 200,
  "https": true,
  "truncated": false,
  "fetchError": null,
  "resourceCount": 2,
  "thirdPartyCount": 1,
  "missingIntegrityCount": 1,
  "weakHashCount": 0,
  "invalidIntegrityCount": 0,
  "missingCrossoriginCount": 0,
  "insecureResourceCount": 0,
  "resources": [
    {
      "tag": "script",
      "url": "https://cdn.example.net/app.js",
      "thirdParty": true,
      "hasIntegrity": false,
      "algorithms": [],
      "validIntegrityFormat": false,
      "weakHash": false,
      "crossorigin": null,
      "https": true,
      "issues": ["Third-party resource is missing Subresource Integrity."],
      "recommendation": "Third-party resource is missing Subresource Integrity."
    }
  ],
  "issues": ["Third-party resource is missing Subresource Integrity."],
  "score": 80,
  "grade": "B",
  "checkedAt": "2026-09-11T00:00:00.000Z",
  "recommendations": ["Add integrity hashes to third-party scripts and stylesheets that are stable enough to pin."]
}
```

### Security

The actor accepts only public HTTP and HTTPS URLs. It rejects URL credentials, private IPv4 and IPv6 literals, and hostnames that resolve to private IP ranges. Redirect targets are revalidated before following. The actor fetches only the input page HTML and does not fetch discovered script or stylesheet URLs.

### Pricing suggestion

| Event | Suggested price |
| --- | ---: |
| Actor start | `$0.005` |
| Page audited | `$0.01` |

Suggested total for a typical run: about `$0.015` per audited page.

### FAQ

#### Does this verify the remote file hash?

No. It audits page markup for SRI posture and does not fetch discovered resources. This keeps runs fast, bounded, and safer for SSRF control.

#### Why are first-party resources not counted as missing SRI?

SRI is most valuable for third-party CDN resources. First-party resources are still listed, but missing integrity on same-site files is not scored as a defect.

#### Does it run JavaScript?

No. It reads the initial HTML response only. Browser-rendered resources are outside this actor's scope.

# Actor input Schema

## `startUrl` (type: `string`):

Public page URL to audit. HTTP and HTTPS only. Private IP ranges are blocked.

## `timeoutSeconds` (type: `integer`):

Timeout for the HTTP request.

## `maxHtmlBytes` (type: `integer`):

Maximum HTML body size to download and parse.

## Actor input object example

```json
{
  "startUrl": "https://example.com",
  "timeoutSeconds": 10,
  "maxHtmlBytes": 1048576
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "startUrl": "https://example.com"
};

// Run the Actor and wait for it to finish
const run = await client.actor("phoenix2810/subresource-integrity-auditor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "startUrl": "https://example.com" }

# Run the Actor and wait for it to finish
run = client.actor("phoenix2810/subresource-integrity-auditor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "startUrl": "https://example.com"
}' |
apify call phoenix2810/subresource-integrity-auditor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,phoenix2810/subresource-integrity-auditor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/CZehrpPvo44QhBKJC/builds/BkY5tdx59jjxsGhx5/openapi.json
