# Repository Tree Publication Leak Gate for Static Hosts (`kingii98/repository-tree-publication-leak-gate-for-static-hosts`) Actor

Find repository files outside the publish directory that your live static site serves.

- **URL**: https://apify.com/kingii98/repository-tree-publication-leak-gate-for-static-hosts.md
- **Developed by:** [kingii98](https://apify.com/kingii98) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 repository snapshot loadeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## 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

## Repository Tree Publication Leak Gate for Static Hosts

This Actor finds repository files that your live static site serves but should not.
It takes the file list of your repository. It sends requests to your origin for each file outside the publish directory.
Where possible, it proves that the served file is the repository file. It compares the git blob SHA-1 hash.

### Input

| Field | Meaning |
| --- | --- |
| `origin` | HTTPS URL of the deployed site. Private and reserved addresses are rejected. |
| `ownershipAttested` | You must tick this box to confirm that you own the origin. Default is `false`. Without it, the Actor sends no request to the origin. |
| `githubRepo` | Optional. `owner/name@ref` of a public repository. The Actor loads the file list with one call to the GitHub git trees API (`recursive=1`). It ignores `pathList` when you set this field. |
| `githubToken` | Optional secret. A read-only token. It raises the GitHub rate limit. |
| `pathList` | Optional. Repository-relative paths, for example from `git ls-files`. |
| `publishDir` | Paths inside this directory are expected to be public. |
| `allowPublicPaths` | Glob patterns for paths that are public on purpose, for example `CNAME`. A pattern without `/` also matches the file name at any depth. |
| `maxPaths` | Default 2000. Hard cap 10000. |

Empty input `{}` succeeds. Because `ownershipAttested` defaults to `false`, an empty-input run sends no request to the origin. It writes a summary with `gate` = `fail` and a reason. It does not end FAILED.

### How a path is checked

1. Paths inside `publishDir` or that match `allowPublicPaths` get the verdict `expected_public`. The Actor does not request them.
2. For each other path, the Actor sends one `HEAD` request. It uses `GET` if the origin answers 405 or 501.
3. If the status is 200, the Actor downloads at most 1 MB with `GET`.
4. If the repository snapshot gives a blob SHA, the Actor compares it with the SHA-1 of the served bytes (`blob <size>\0<bytes>`).
   - Match: `servedBlobShaMatches` = `true`, verdict `exposed`.
   - No match: `servedBlobShaMatches` = `false`, verdict `not_served`. The origin probably returns a catch-all page.
   - No SHA (`pathList`) or body larger than 1 MB: `servedBlobShaMatches` = `unknown`, verdict `exposed`.
5. Other results give the verdict `not_served`.

The Actor follows at most 3 redirects. It follows only redirects to the same HTTPS host.

### Output

The dataset has one item per path (`recordType` = `path`) with: `repoPath`, `probedUrl`, `httpStatus`, `contentType`, `bytes`, `servedBlobShaMatches`, `riskClass`, `verdict`.
The last dataset item is the summary (`recordType` = `summary`). The same record is in the key-value store under `SUMMARY`.
The summary has `gate` (`pass` or `fail`), `reason`, `exposedCount`, `exposedByRiskClass`, and `firstExposedPaths` (first 20).

A failed gate, an unreachable target, a bad input, and zero findings are results. The run still ends SUCCEEDED.
The gate is `fail` when a path is exposed or when the Actor could not finish the check (see `reason`).

### Pricing events (pay per event)

| Event | When the Actor charges |
| --- | --- |
| `repository-snapshot-loaded` | Once, after the GitHub tree loads and parses. Not charged for `pathList`. |
| `path-probed` | Once for each path that the Actor probes on the origin. Paths with the verdict `expected_public` are not probed and not charged. |

If the charge limit is reached, the Actor stops. It sets `gate` = `fail` with a reason.

### Limits

- The Actor does not detect a catch-all origin (single-page app) when no blob SHA is available. Use `githubRepo` for hash proof.
- The check of the origin address happens before the requests. It does not stop DNS rebinding.
- GitHub unauthenticated limit is 60 requests per hour per IP. Use `githubToken` or `pathList`.
- If GitHub marks the tree as truncated, the summary notes it.
- The Actor uses HTTP only. It uses no browser, proxy, or LLM.

### Development

```
uv run pytest
uv run ruff check .
```

# Actor input Schema

## `origin` (type: `string`):

HTTPS URL of the deployed site. You must own it.

## `ownershipAttested` (type: `boolean`):

Tick this box to confirm that you own the origin. The Actor sends no request to the origin without it.

## `githubRepo` (type: `string`):

Optional. Format owner/name@ref for a public repository. The Actor loads the file list from the GitHub git trees API. If you set this, the Actor ignores Path list.

## `githubToken` (type: `string`):

Optional. A read-only token. It raises the GitHub API rate limit.

## `pathList` (type: `array`):

Repository-relative paths, for example the output of git ls-files. Use it instead of GitHub repository.

## `publishDir` (type: `string`):

Paths inside this directory are expected to be public. Example: dist/ or \_site/.

## `allowPublicPaths` (type: `array`):

Glob patterns for paths that are public on purpose, for example CNAME or .nojekyll.

## `maxPaths` (type: `integer`):

Maximum number of paths to check. Hard cap 10000.

## Actor input object example

```json
{
  "origin": "https://example.com/",
  "ownershipAttested": false,
  "pathList": [
    "README.md",
    "package.json",
    ".github/workflows/deploy.yml"
  ],
  "publishDir": "dist/",
  "allowPublicPaths": [
    "CNAME",
    ".nojekyll"
  ],
  "maxPaths": 2000
}
```

# Actor output Schema

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

No description

## `summary` (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 = {
    "origin": "https://example.com/",
    "ownershipAttested": false,
    "pathList": [
        "README.md",
        "package.json",
        ".github/workflows/deploy.yml"
    ],
    "publishDir": "dist/",
    "allowPublicPaths": [
        "CNAME",
        ".nojekyll"
    ],
    "maxPaths": 2000
};

// Run the Actor and wait for it to finish
const run = await client.actor("kingii98/repository-tree-publication-leak-gate-for-static-hosts").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 = {
    "origin": "https://example.com/",
    "ownershipAttested": False,
    "pathList": [
        "README.md",
        "package.json",
        ".github/workflows/deploy.yml",
    ],
    "publishDir": "dist/",
    "allowPublicPaths": [
        "CNAME",
        ".nojekyll",
    ],
    "maxPaths": 2000,
}

# Run the Actor and wait for it to finish
run = client.actor("kingii98/repository-tree-publication-leak-gate-for-static-hosts").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 '{
  "origin": "https://example.com/",
  "ownershipAttested": false,
  "pathList": [
    "README.md",
    "package.json",
    ".github/workflows/deploy.yml"
  ],
  "publishDir": "dist/",
  "allowPublicPaths": [
    "CNAME",
    ".nojekyll"
  ],
  "maxPaths": 2000
}' |
apify call kingii98/repository-tree-publication-leak-gate-for-static-hosts --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,kingii98/repository-tree-publication-leak-gate-for-static-hosts"
        }
    }
}
```

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/aX0T0a8pOlNdCG41Y/builds/tWnhctprv6Mkom1JJ/openapi.json
