Scanners
Note
These APIs are subject to change at any time and are for internal use only.
Post - Push results
This endpoint allows a scanner to push results for an existing version.
Note
Requires JWT authentication using the service account credentials associated with the scanner webhook.
- POST /api/v5/scanner/results/
- Request JSON Object:
version_id (integer) – The primary key of the add-on version.
results (object) – The scanner results.
- Status Codes:
201 Created – Result created successfully.
400 Bad Request – Invalid payload.
403 Forbidden – Authentication failed or the authenticated user is not the service account of an active webhook with a push event.
409 Conflict – One or more of the matched rules have already been pushed for this version.
Patch - Update results
This endpoint allows to update scanner results.
Note
Requires JWT authentication using the service account credentials associated with the scanner webhook.
- PATCH /api/v5/scanner/results/(int: pk)/
- Query Parameters:
id (string) – The scanner result ID.
- Request JSON Object:
results (object) – The scanner results.
- Status Codes:
204 No Content – Results successfully updated.
400 Bad Request – Invalid payload.
409 Conflict – Scanner results already recorded.
Query rules
These endpoints allow authorized users to create and run ScannerQueryRule
objects and to read their matches.
Note
Requires JWT authentication. The authenticated user must belong to a group with the
Admin:ScannersQueryViewpermission for read operations, andAdmin:ScannersQueryEditfor create, update, delete, run and abort operations.
A rule can only be edited while it is in the new state; once it has been
scheduled or run its definition is frozen and a new rule should be created to
iterate on it. name and scanner are also frozen after creation and can
only be set when the rule is created.
For yara rules the name is inferred from the definition (the
rule <name> identifier); any name sent by the client is ignored. For
narc rules the name is required.
The scanner field accepts yara or narc. The state field is one
of new, running, aborted, completed, aborting or
scheduled.
Configuration
Only narc rules have configuration options. configuration is an object
whose keys are booleans; unknown keys or non-boolean values are rejected. When
omitted at creation, it is populated with the defaults noted below. yara
rules must not have any configuration.
examine_slug(defaultfalse): Run the rule against the add-on slug used for the listing on AMO.examine_listing_names(defaulttrue): Run against the add-on name(s) used for the listing on AMO.examine_listing_summaries(defaultfalse): Run against the add-on summary/summaries used for the listing on AMO.examine_xpi_names(defaulttrue): Run against the add-on name(s) in the XPI.examine_xpi_descriptions(defaultfalse): Run against the add-on description(s) in the XPI.examine_authors_names(defaulttrue): Run against the name of each author attached to the add-on.examine_normalized_variants(defaulttrue): For each string being examined, also examine a normalized variant.examine_homoglyphs_variants(defaulttrue): For each string being examined, also examine homoglyph variants.
List / create rules
- GET /api/v5/scanner/query-rules/
Return a paginated list of query rules, most recently created first.
- Response JSON Object:
count (int) – The number of rules.
results (array) – The array of rules (see the fields below).
- Status Codes:
200 OK – Rules returned successfully.
401 Unauthorized – Authentication failed.
403 Forbidden – The authenticated user lacks the required permission.
- POST /api/v5/scanner/query-rules/
Create a new query rule. The definition is validated (YARA/NARC compilation and, for YARA, that the rule name matches the
namefield).- Request JSON Object:
name (string) – The exact name of the rule (frozen after creation). Required for
narc; ignored and inferred from the definition foryara.scanner (string) –
yaraornarc(required, frozen after creation).definition (string) – The rule definition (required).
pretty_name (string) – Human-readable name (optional).
description (string) – Human-readable description (optional).
configuration (object) – Scanner-specific configuration (optional, see above).
run_on_disabled_addons (boolean) – Run on force-disabled add-ons too (optional).
run_on_current_version_only (boolean) – Run on the current listed version only (optional).
run_on_specific_channel (string) – Restrict to a channel,
unlistedorlisted(optional).exclude_promoted_addons (boolean) – Exclude promoted add-ons (optional).
- Response JSON Object:
id (int) – The primary key of the created rule.
scanner (string) – The scanner (
yaraornarc).state (string) – The rule state (
newfor a freshly created rule).completion_rate (string) – Progress string while running, otherwise
null.results_count (int) – Number of matches recorded so far.
- Status Codes:
201 Created – Rule created successfully.
400 Bad Request – Invalid payload (e.g. the definition does not compile).
401 Unauthorized – Authentication failed.
403 Forbidden – The authenticated user lacks the required permission.
Retrieve / update / delete a rule
- GET /api/v5/scanner/query-rules/(int: pk)/
Return a single query rule. Poll this endpoint to track a run via the
state,completion_rateandcompletedfields.- Status Codes:
200 OK – Rule returned successfully.
401 Unauthorized – Authentication failed.
403 Forbidden – The authenticated user lacks the required permission.
404 Not Found – No rule with that id.
- PATCH /api/v5/scanner/query-rules/(int: pk)/
Update a query rule. Only allowed while the rule is in the
Newstate. Accepts the same writable fields as the create endpoint.- Status Codes:
200 OK – Rule updated successfully.
400 Bad Request – Invalid payload, or the rule is not in the
Newstate.401 Unauthorized – Authentication failed.
403 Forbidden – The authenticated user lacks the required permission.
404 Not Found – No rule with that id.
- DELETE /api/v5/scanner/query-rules/(int: pk)/
Delete a query rule and its results.
- Status Codes:
204 No Content – Rule deleted successfully.
401 Unauthorized – Authentication failed.
403 Forbidden – The authenticated user lacks the required permission.
404 Not Found – No rule with that id.
Run / abort a rule
- POST /api/v5/scanner/query-rules/(int: pk)/run/
Schedule the rule to run. The rule transitions to the
Scheduledstate and a background task is enqueued.- Response JSON Object:
state (string) – The updated state (
scheduled).
- Status Codes:
202 Accepted – Run scheduled successfully.
401 Unauthorized – Authentication failed.
403 Forbidden – The authenticated user lacks the required permission.
404 Not Found – No rule with that id.
409 Conflict – The rule is not in a state from which it can be run.
- POST /api/v5/scanner/query-rules/(int: pk)/abort/
Abort a scheduled or running rule. The rule transitions to the
Abortingstate.- Status Codes:
200 OK – Abort requested successfully.
401 Unauthorized – Authentication failed.
403 Forbidden – The authenticated user lacks the required permission.
404 Not Found – No rule with that id.
409 Conflict – The rule is not in a state from which it can be aborted.
Rule results
- GET /api/v5/scanner/query-rules/(int: query_rule_pk)/results/
Return a paginated list of the matches for a rule. Only the definition-safe match information is exposed (the files and metadata that hit), not the raw scanner output.
The list can be filtered and ordered with the query parameters below. Invalid filter values return a
400.- Query Parameters:
was_blocked (boolean) – Only results whose version was blocked.
was_promoted (boolean) – Only results whose add-on was promoted.
was_signed (boolean) – Only results whose file is signed.
addon_disabled_by_user (boolean) – Only results whose add-on listing is invisible (
true) or visible (false).channel (string) – Version channel,
unlistedorlisted.addon_status (string) – Add-on status (e.g.
public,disabled).file_status (string) – File status (e.g.
public,disabled).sort (string) – Ordering field. One of
id,addon_adu(add-on average daily users) orversion_created. Prefix with-for descending order (e.g.-addon_adu). Defaults to-id.
- Response JSON Object:
count (int) – The number of results.
results (array) – The array of results.
results[].id (int) – The result id.
results[].was_blocked (boolean) – Whether the version was blocked.
results[].was_promoted (boolean) – Whether the add-on was promoted.
results[].version (object) – Minimal version representation (may be
null).results[].version.id (int) – The version id.
results[].version.version (string) – The version number.
results[].version.channel (string) – The version channel (
listedorunlisted).results[].version.created (string) – When the version was created.
results[].version.addon (object) – The add-on (
id,guid,average_daily_users).results[].matches (object) – The matched files and metadata, keyed by rule name.
results[].created (string) – When the result was recorded.
- Status Codes:
200 OK – Results returned successfully.
401 Unauthorized – Authentication failed.
403 Forbidden – The authenticated user lacks the required permission.
404 Not Found – No rule with that id.