AbstractAuditParser
API reference › Foxy › Audit › Parser › AbstractAuditParser
5 subclasses
Provides strict validation and normalization helpers for audit output parsers.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
assertNotErrorDocument() protected final | Rejects a JSON document that represents a package manager error. | AbstractAuditParser |
assertOutputSize() protected final | Rejects audit output that exceeds the parser’s size limit. | AbstractAuditParser |
decodeObject() protected final | Decodes an audit JSON object after validating its size and shape. | AbstractAuditParser |
getAdvisoryId() protected final | Selects a GHSA identifier from the candidate or URL, falling back to the source identifier. | AbstractAuditParser |
getBoolean() protected final | Returns a required boolean field. | AbstractAuditParser |
getCves() protected final | Returns validated, normalized CVE identifiers. | AbstractAuditParser |
getGhsaId() protected final | Extracts and normalizes a GHSA identifier from a value or URL. | AbstractAuditParser |
getManagerName() protected abstract | Returns the package manager name used in malformed-output errors. | AbstractAuditParser |
getNonNegativeInteger() protected final | Returns a required non-negative integer field. | AbstractAuditParser |
getObject() protected final | Converts a decoded JSON object into its property map. | AbstractAuditParser |
getOptionalString() protected final | Returns a sanitized optional string field, or null when absent or empty. | AbstractAuditParser |
getSeverity() protected final | Returns a supported normalized severity value. | AbstractAuditParser |
getSeverityCount() protected final | Returns the sum of severity counts and optionally validates the reported total. | AbstractAuditParser |
getSourceId() protected final | Returns a non-empty source identifier from a string or integer value. | AbstractAuditParser |
getString() protected final | Returns a required sanitized string field. | AbstractAuditParser |
getStringList() protected final | Returns a normalized list containing only strings. | AbstractAuditParser |
malformed() protected final | Creates a package-manager-specific malformed-output exception. | AbstractAuditParser |
sanitizeString() protected final | Replaces control characters and trims surrounding whitespace. | AbstractAuditParser |
uniqueStrings() protected final | Returns unique strings in deterministic order. | AbstractAuditParser |
Method details
Section titled “Method details”assertNotErrorDocument()
Section titled “assertNotErrorDocument() ”final protected function assertNotErrorDocument(mixed[] $data): voidRejects a JSON document that represents a package manager error.
Parameters
| Parameter | Type | Description |
|---|---|---|
$data | mixed[] |
assertOutputSize()
Section titled “assertOutputSize() ”final protected function assertOutputSize(string $output): voidRejects audit output that exceeds the parser’s size limit.
Parameters
| Parameter | Type | Description |
|---|---|---|
$output | string |
decodeObject()
Section titled “decodeObject() ”final protected function decodeObject(string $output): mixed[]Decodes an audit JSON object after validating its size and shape.
Parameters
| Parameter | Type | Description |
|---|---|---|
$output | string |
Returns
mixed[]
getAdvisoryId()
Section titled “getAdvisoryId() ”final protected function getAdvisoryId(string $sourceId, string|null $candidate, string|null $url): stringSelects a GHSA identifier from the candidate or URL, falling back to the source identifier.
Parameters
| Parameter | Type | Description |
|---|---|---|
$sourceId | string | |
$candidate | string| | |
$url | string| |
Returns
string
getBoolean()
Section titled “getBoolean() ”final protected function getBoolean(array $data, string $key, string $context): boolReturns a required boolean field.
Parameters
| Parameter | Type | Description |
|---|---|---|
$data | array | |
$key | string | |
$context | string |
Returns
bool
getCves()
Section titled “getCves() ”final protected function getCves(mixed $value, string $context): list<string>Returns validated, normalized CVE identifiers.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | mixed | |
$context | string |
Returns
list<string>
getGhsaId()
Section titled “getGhsaId() ”final protected function getGhsaId(string|null $value): string|nullExtracts and normalizes a GHSA identifier from a value or URL.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | string| |
Returns
string|null
getManagerName()
Section titled “getManagerName() ”abstract protected function getManagerName(): stringReturns the package manager name used in malformed-output errors.
Returns
string
getNonNegativeInteger()
Section titled “getNonNegativeInteger() ”final protected function getNonNegativeInteger(array $data, string $key, string $context): intReturns a required non-negative integer field.
Parameters
| Parameter | Type | Description |
|---|---|---|
$data | array | |
$key | string | |
$context | string |
Returns
int
getObject()
Section titled “getObject() ”final protected function getObject(mixed $value, string $context): mixed[]Converts a decoded JSON object into its property map.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | mixed | |
$context | string |
Returns
mixed[]
getOptionalString()
Section titled “getOptionalString() ”final protected function getOptionalString(array $data, string $key, string $context): string|nullReturns a sanitized optional string field, or null when absent or empty.
Parameters
| Parameter | Type | Description |
|---|---|---|
$data | array | |
$key | string | |
$context | string |
Returns
string|null
getSeverity()
Section titled “getSeverity() ”final protected function getSeverity(mixed $value, string $context): Foxy\Audit\SeverityReturns a supported normalized severity value.
getSeverityCount()
Section titled “getSeverityCount() ”final protected function getSeverityCount(array $metadata, string $context, bool $requireTotal): intReturns the sum of severity counts and optionally validates the reported total.
Parameters
| Parameter | Type | Description |
|---|---|---|
$metadata | array | |
$context | string | |
$requireTotal | bool |
Returns
int
getSourceId()
Section titled “getSourceId() ”final protected function getSourceId(mixed $value, string $context): stringReturns a non-empty source identifier from a string or integer value.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | mixed | |
$context | string |
Returns
string
getString()
Section titled “getString() ”final protected function getString(array $data, string $key, string $context, bool $allowEmpty = false): stringReturns a required sanitized string field.
Parameters
| Parameter | Type | Description |
|---|---|---|
$data | array | |
$key | string | |
$context | string | |
$allowEmpty | bool |
Returns
string
getStringList()
Section titled “getStringList() ”final protected function getStringList(mixed $value, string $context): list<string>Returns a normalized list containing only strings.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | mixed | |
$context | string |
Returns
list<string>
malformed()
Section titled “malformed() ”final protected function malformed(string $reason, Throwable|null $previous = null): Foxy\Exception\RuntimeExceptionCreates a package-manager-specific malformed-output exception.
sanitizeString()
Section titled “sanitizeString() ”final protected function sanitizeString(string $value): stringReplaces control characters and trims surrounding whitespace.
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | string |
Returns
string
uniqueStrings()
Section titled “uniqueStrings() ”final protected function uniqueStrings(list<string> $values): list<string>Returns unique strings in deterministic order.
Parameters
| Parameter | Type | Description |
|---|---|---|
$values | list<string> |
Returns
list<string>