# Browser Extension Declared-Against-Used Permission Minimality (`kingii98/browser-extension-declared-against-used-permission-minimality`) Actor

Find permissions that an extension manifest declares but the code does not use.

- **URL**: https://apify.com/kingii98/browser-extension-declared-against-used-permission-minimality.md
- **Developed by:** [kingii98](https://apify.com/kingii98) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$30.00 / 1,000 package analyzeds

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

## Browser Extension Permission Minimality Gate

This Actor finds permissions that an extension manifest declares but the code does not use.
Run it before you upload a release to the Chrome Web Store.

### Input

| Field | Type | Default | Description |
| --- | --- | --- | --- |
| `packages` | array of strings | one Chrome Web Store ID | Up to 20 public ZIP or CRX URLs, or Chrome Web Store extension IDs. Each package must be 50 MB or less. |

An empty input `{}` uses the default value. The run succeeds.

### Output

The default dataset has two row types.

**Permission row** (`type: "permission"`), one for each declared permission:
`package`, `extension_name`, `extension_version`, `permission`, `declared_in`,
`verdict` (`used`, `unused`, or `unknown`), `api_references`, `file_paths`, `note`.

**Summary row** (`type: "summary"`), one for each package:
`result` (`pass` or `fail`), `analysis_status`, `declared_count`, `used_count`,
`unused_count`, `unknown_count`, `unused_permissions`, `files_scanned`, `error`.

#### Rules

- `result` is `fail` when at least one permission is `unused`. Otherwise it is `pass`.
- `unknown` never causes a `fail`.
- A package that cannot be analyzed gets `result: "fail"` and an `analysis_status` of
  `unreachable`, `invalid_package`, or `invalid_input`. The `error` field gives the reason.
  These are results. The run still ends SUCCEEDED.

### Pricing event

| Event name | Unit | Price (USD) |
| --- | --- | --- |
| `package-analyzed` | One extension package that was downloaded and scanned | 0.03 |

The Actor makes one `Actor.charge` call with count 1 for each analyzed package.
It does not charge for packages that are unreachable, invalid, or rejected by input checks.
If the maximum total charge limit is reached, the Actor stops and keeps the results that it
already stored. The default limit of USD 0.60 covers the maximum of 20 packages.

The price is set in the Apify Console. This repository does not change pricing.

### How the scan works

1. The Actor downloads the package with HTTP only. It uses no browser, proxy, or paid API.
2. It reads the ZIP or CRX in memory. It does not run any code from the package.
3. It reads `manifest.json` and the permissions in `permissions`, `optional_permissions`,
   `host_permissions`, and `optional_host_permissions`.
4. It scans `.js`, `.mjs`, `.cjs`, and `.html` files for `chrome.*` and `browser.*` API calls.

### Limits and safety

- Download limits: 50 MB for each package, 3 redirects, 90 seconds, 4 downloads at a time.
- Archive limits: 5000 files, 250 MB unpacked, 5 MB for each script, 100 MB scanned in total.
- The Actor rejects URLs that use a scheme other than http or https, a port other than 80 or
  443, credentials in the URL, or a host that resolves to a private or reserved address.
  It checks each redirect. The Actor resolves the host name one time for each request. It
  connects to the address that it approved. It keeps the host name for the Host header and
  for TLS (Transport Layer Security).
- A static scan can give a wrong answer. The Actor gives `unknown`, not `unused`, when:
  code reads APIs in a dynamic way (for example `chrome[name]`, `eval`, or
  `const api = chrome;`), when some files were too large or unreadable, when the permission
  has no detectable API (for example `unlimitedStorage`), for `tabs` when `chrome.tabs`
  calls exist, and for `activeTab` when `chrome.tabs` calls, `chrome.tabCapture`, or a
  user-action entry point exist. The entry points are `action.onClicked`,
  `browserAction.onClicked`, `pageAction.onClicked`, `contextMenus.onClicked`,
  `menus.onClicked`, and `commands.onCommand`.
- Comments and strings that look like API calls count as use. A permission can show `used`
  when only a comment names the API.
- A host permission is `used` when a content script matches it or the host name appears in the
  code. It is `unknown` when the code makes network or injection calls. Otherwise it is `unused`.
- Packages can be remote and untrusted. The Actor never writes archive files to disk.

### Local development

```
uv sync
uv run pytest
uv run ruff check .
apify run --input-file .actor/default_input.json
```

# Actor input Schema

## `packages` (type: `array`):

Up to 20 public ZIP or CRX URLs, or Chrome Web Store extension IDs (32 letters, a to p). Each package must be 50 MB or less.

## Actor input object example

```json
{
  "packages": [
    "ddkjiahejlhfcafbddmgiahcphecmpfh"
  ]
}
```

# 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 = {
    "packages": [
        "ddkjiahejlhfcafbddmgiahcphecmpfh"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("kingii98/browser-extension-declared-against-used-permission-minimality").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 = { "packages": ["ddkjiahejlhfcafbddmgiahcphecmpfh"] }

# Run the Actor and wait for it to finish
run = client.actor("kingii98/browser-extension-declared-against-used-permission-minimality").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 '{
  "packages": [
    "ddkjiahejlhfcafbddmgiahcphecmpfh"
  ]
}' |
apify call kingii98/browser-extension-declared-against-used-permission-minimality --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,kingii98/browser-extension-declared-against-used-permission-minimality"
        }
    }
}
```

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/Q2MkkIhiU2tzBdjmn/builds/6anppzevKMG6GS56A/openapi.json
