Skip to content

Commit 8c833ec

Browse files
committed
types/v1: add JSON API v1 types and schemas
Signed-off-by: Hank Donnay <[email protected]>
1 parent 1b42959 commit 8c833ec

28 files changed

+1028
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"$id": "https://clairproject.org/api/http/v1/affected_manifests.schema.json",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
4+
"title": "Affected Manifests",
5+
"type": "object",
6+
"description": "**This is an internal type, documented for completeness.**\n\nManifests affected by the specified vulnerability objects.",
7+
"properties": {
8+
"vulnerabilities": {
9+
"type": "object",
10+
"description": "Vulnerability objects.",
11+
"additionalProperties": {
12+
"$ref": "vulnerability.schema.json"
13+
}
14+
},
15+
"vulnerable_manifests": {
16+
"type": "object",
17+
"description": "Mapping of manifest digests to vulnerability identifiers.",
18+
"additionalProperties": {
19+
"type": "array",
20+
"items": {
21+
"type": "string",
22+
"description": "An identifier to be used in the \"vulnerabilities\" object."
23+
}
24+
}
25+
}
26+
},
27+
"required": [
28+
"vulnerabilities",
29+
"vulnerable_manifests"
30+
]
31+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$id": "https://clairproject.org/api/http/v1/bulk_delete.schema.json",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
4+
"title": "Bulk Delete",
5+
"type": "array",
6+
"description": "Array of manifest digests to delete from the system.",
7+
"items": {
8+
"$ref": "digest.schema.json",
9+
"description": "Manifest digest to delete from the system."
10+
}
11+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$id": "https://clairproject.org/api/http/v1/cpe.schema.json",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
4+
"title": "Common Platform Enumeration Name",
5+
"description": "This is a CPE Name in either v2.2 \"URI\" form or v2.3 \"Formatted String\" form.",
6+
"$comment": "Clair only produces v2.3 CPE Names. Any v2.2 Names will be normalized into v2.3 form.",
7+
"oneOf": [
8+
{
9+
"description": "This is the CPE 2.2 regexp: https://cpe.mitre.org/specification/2.2/cpe-language_2.2.xsd",
10+
"type": "string",
11+
"pattern": "^[c][pP][eE]:/[AHOaho]?(:[A-Za-z0-9\\._\\-~%]*){0,6}$"
12+
},
13+
{
14+
"description": "This is the CPE 2.3 regexp: https://csrc.nist.gov/schema/cpe/2.3/cpe-naming_2.3.xsd",
15+
"type": "string",
16+
"pattern": "^cpe:2\\.3:[aho\\*\\-](:(((\\?*|\\*?)([a-zA-Z0-9\\-\\._]|(\\\\[\\\\\\*\\?!\"#$$%&'\\(\\)\\+,/:;<=>@\\[\\]\\^`\\{\\|}~]))+(\\?*|\\*?))|[\\*\\-])){5}(:(([a-zA-Z]{2,3}(-([a-zA-Z]{2}|[0-9]{3}))?)|[\\*\\-]))(:(((\\?*|\\*?)([a-zA-Z0-9\\-\\._]|(\\\\[\\\\\\*\\?!\"#$$%&'\\(\\)\\+,/:;<=>@\\[\\]\\^`\\{\\|}~]))+(\\?*|\\*?))|[\\*\\-])){4}$"
17+
}
18+
]
19+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"$id": "https://clairproject.org/api/http/v1/digest.schema.json",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
4+
"title": "Digest",
5+
"description": "A digest acts as a content identifier, enabling content addressability.",
6+
"type": "string",
7+
"anyOf": [
8+
{
9+
"$comment": "SHA256: MUST be implemented",
10+
"description": "SHA256",
11+
"type": "string",
12+
"pattern": "^sha256:[a-f0-9]{64}$"
13+
},
14+
{
15+
"$comment": "SHA512: MAY be implemented",
16+
"description": "SHA512",
17+
"type": "string",
18+
"pattern": "^sha512:[a-f0-9]{128}$"
19+
},
20+
{
21+
"$comment": "BLAKE3: MAY be implemented",
22+
"description": "BLAKE3\n\n**Currently not implemented.**",
23+
"type": "string",
24+
"pattern": "^blake3:[a-f0-9]{64}$"
25+
}
26+
]
27+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"$id": "https://clairproject.org/api/http/v1/distribution.schema.json",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
4+
"title": "Distribution",
5+
"type": "object",
6+
"description": "Distribution is the accompanying system context of a Package.",
7+
"properties": {
8+
"id": {
9+
"description": "Unique ID for this Distribution. May be unique to the response document, not the whole system.",
10+
"type": "string"
11+
},
12+
"did": {
13+
"description": "A lower-case string (no spaces or other characters outside of 0–9, a–z, \".\", \"_\", and \"-\") identifying the operating system, excluding any version information and suitable for processing by scripts or usage in generated filenames.",
14+
"type": "string"
15+
},
16+
"name": {
17+
"description": "A string identifying the operating system.",
18+
"type": "string"
19+
},
20+
"version": {
21+
"description": "A string identifying the operating system version, excluding any OS name information, possibly including a release code name, and suitable for presentation to the user.",
22+
"type": "string"
23+
},
24+
"version_code_name": {
25+
"description": "A lower-case string (no spaces or other characters outside of 0–9, a–z, \".\", \"_\", and \"-\") identifying the operating system release code name, excluding any OS name information or release version, and suitable for processing by scripts or usage in generated filenames.",
26+
"type": "string"
27+
},
28+
"version_id": {
29+
"description": "A lower-case string (mostly numeric, no spaces or other characters outside of 0–9, a–z, \".\", \"_\", and \"-\") identifying the operating system version, excluding any OS name information or release code name.",
30+
"type": "string"
31+
},
32+
"arch": {
33+
"description": "A string identifying the OS architecture.",
34+
"type": "string"
35+
},
36+
"cpe": {
37+
"description": "Common Platform Enumeration name.",
38+
"$ref": "cpe.schema.json"
39+
},
40+
"pretty_name": {
41+
"description": "A pretty operating system name in a format suitable for presentation to the user.",
42+
"type": "string"
43+
}
44+
},
45+
"additionalProperties": false,
46+
"required": [
47+
"id"
48+
]
49+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"$id": "https://clairproject.org/api/http/v1/environment.schema.json",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
4+
"title": "Environment",
5+
"type": "object",
6+
"description": "Environment describes the surrounding environment a package was discovered in.",
7+
"properties": {
8+
"package_db": {
9+
"description": "The database the associated Package was discovered in.",
10+
"type": "string"
11+
},
12+
"distribution_id": {
13+
"description": "The ID of the Distribution of the associated Package.",
14+
"type": "string"
15+
},
16+
"introduced_in": {
17+
"description": "The Layer the associated Package was introduced in.",
18+
"$ref": "digest.schema.json"
19+
},
20+
"repository_ids": {
21+
"description": "The IDs of the Repositories of the associated Package.",
22+
"type": "array",
23+
"items": {
24+
"type": "string"
25+
}
26+
}
27+
},
28+
"additionalProperties": false
29+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$id": "https://clairproject.org/api/http/v1/error.schema.json",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
4+
"title": "Error",
5+
"type": "object",
6+
"description": "A general error response.",
7+
"properties": {
8+
"code": {
9+
"type": "string",
10+
"description": "a code for this particular error"
11+
},
12+
"message": {
13+
"type": "string",
14+
"description": "a message with further detail"
15+
}
16+
},
17+
"required": [
18+
"message"
19+
]
20+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"$id": "https://clairproject.org/api/http/v1/index_report.schema.json",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
4+
"title": "Index Report",
5+
"type": "object",
6+
"description": "An index of the contents of a Manifest.",
7+
"properties": {
8+
"manifest_hash": {
9+
"$ref": "digest.schema.json",
10+
"description": "The Manifest's digest."
11+
},
12+
"state": {
13+
"type": "string",
14+
"description": "The current state of the index operation"
15+
},
16+
"err": {
17+
"type": "string",
18+
"description": "An error message on event of unsuccessful index"
19+
},
20+
"success": {
21+
"type": "boolean",
22+
"description": "A bool indicating succcessful index"
23+
},
24+
"packages": {
25+
"type": "object",
26+
"description": "A map of Package objects indexed by a document-local identifier.",
27+
"additionalProperties": {
28+
"$ref": "package.schema.json"
29+
}
30+
},
31+
"distributions": {
32+
"type": "object",
33+
"description": "A map of Distribution objects indexed by a document-local identifier.",
34+
"additionalProperties": {
35+
"$ref": "distribution.schema.json"
36+
}
37+
},
38+
"repository": {
39+
"type": "object",
40+
"description": "A map of Repository objects indexed by a document-local identifier.",
41+
"additionalProperties": {
42+
"$ref": "repository.schema.json"
43+
}
44+
},
45+
"environments": {
46+
"type": "object",
47+
"description": "A map of Environment arrays indexed by a Package's identifier.",
48+
"additionalProperties": {
49+
"type": "array",
50+
"items": {
51+
"$ref": "environment.schema.json"
52+
}
53+
}
54+
}
55+
},
56+
"additionalProperties": false,
57+
"required": [
58+
"manifest_hash",
59+
"state",
60+
"success"
61+
]
62+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$id": "https://clairproject.org/api/http/v1/index_state.schema.json",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
4+
"title": "Index State",
5+
"type": "object",
6+
"description": "Information on the state of the indexer system.",
7+
"properties": {
8+
"state": {
9+
"type": "string",
10+
"description": "an opaque token"
11+
}
12+
},
13+
"required": [
14+
"state"
15+
]
16+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"$id": "https://clairproject.org/api/http/v1/layer.schema.json",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
4+
"title": "Layer",
5+
"type": "object",
6+
"description": "Layer is a description of a container layer. It should contain enough information to fetch the layer.",
7+
"properties": {
8+
"hash": {
9+
"$ref": "digest.schema.json",
10+
"description": "Digest of the layer blob."
11+
},
12+
"uri": {
13+
"type": "string",
14+
"description": "A URI indicating where the layer blob can be downloaded from."
15+
},
16+
"headers": {
17+
"description": "Any additional HTTP-style headers needed for requesting layers.",
18+
"type": "object",
19+
"patternProperties": {
20+
"^[a-zA-Z0-9\\-_]+$": {
21+
"type": "array",
22+
"items": {
23+
"type": "string"
24+
}
25+
}
26+
}
27+
},
28+
"media_type": {
29+
"description": "The OCI Layer media type for this layer.",
30+
"type": "string",
31+
"pattern": "^application/vnd\\.oci\\.image\\.layer\\.v1\\.tar(\\+(gzip|zstd))?$"
32+
}
33+
},
34+
"additionalProperties": false,
35+
"required": [
36+
"hash",
37+
"uri"
38+
]
39+
}

0 commit comments

Comments
 (0)