Skip to content

Commit 21a3adb

Browse files
committed
Add example of TEA API
We add an example of statically generated TEA service.
1 parent 5190f4b commit 21a3adb

14 files changed

+352
-0
lines changed

examples/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Simple TEA service example
2+
3+
A simple example of compliant TEA service backed by a filesystem.
4+
5+
You can run the example using any web server with support for content negotiation, even a Python script:
6+
7+
```shell
8+
./run-server.py
9+
```

examples/run-server.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/python3
2+
from http.server import SimpleHTTPRequestHandler
3+
import socketserver
4+
5+
6+
class JsonHTTPRequestHandler(SimpleHTTPRequestHandler):
7+
def translate_path(self, path):
8+
result = super().translate_path(path) + ".json"
9+
# Windows doesn't allow `:` in file names
10+
return result.replace(":", "%3A")
11+
12+
13+
PORT = 8000
14+
with socketserver.TCPServer(("", PORT), JsonHTTPRequestHandler) as httpd:
15+
print("Service at port", PORT)
16+
httpd.serve_forever()

examples/v1/collection.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"timestamp": "2024-03-20T15:30:00Z",
3+
"page_start_index": 0,
4+
"page_size": 2147483647,
5+
"total_results": 3,
6+
"content": [
7+
{
8+
"leaf_uuid": "b0d30215-04f0-462f-84d4-68fcff437f5e",
9+
"uuid": "e697693d-2acf-42af-a0b9-6f85aa84ec10",
10+
"collection_name": "Apache Log4j 1.2.17",
11+
"collection_version": "1",
12+
"release_date": "2015-08-15"
13+
},
14+
{
15+
"leaf_uuid": "1e7d13f3-4c65-40f1-a990-8b85079b2347",
16+
"uuid": "673c62c8-ea5b-4a70-9012-5a8c00aab1e1",
17+
"collection_name": "Apache Log4j 2.23.0",
18+
"collection_version": "1",
19+
"release_date": "2024-02-17"
20+
},
21+
{
22+
"leaf_uuid": "1e7d13f3-4c65-40f1-a990-8b85079b2347",
23+
"uuid": "d750d933-38b2-46af-a8ad-71207ae2b56e",
24+
"collection_name": "Apache Log4j 2.23.1",
25+
"collection_version": "2",
26+
"release_date": "2024-03-06"
27+
}
28+
]
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"leaf_uuid": "1e7d13f3-4c65-40f1-a990-8b85079b2347",
3+
"uuid": "673c62c8-ea5b-4a70-9012-5a8c00aab1e1",
4+
"collection_name": "Apache Log4j 2.23.0",
5+
"collection_version": "1",
6+
"release_date": "2024-02-17",
7+
"author": {
8+
"name": "John Doe",
9+
"email": "john@example.com",
10+
"organization": "The Apache Software Foundation"
11+
},
12+
"reason": "New Product Release",
13+
"artifacts": [
14+
{
15+
"type": "bom",
16+
"mime_type": "application/vnd.cyclonedx+xml",
17+
"url": "https://repo.maven.apache.org/maven2/org/apache/logging/log4j/log4j-bom/2.23.0/log4j-bom-2.23.0-cyclonedx.xml",
18+
"checksums": [
19+
{
20+
"type": "SHA1",
21+
"value": "5f81bb0da6e60a3214b6eacdef3f697a5bb3fad0"
22+
}
23+
]
24+
},
25+
{
26+
"type": "vulnerability-assertion",
27+
"mime_type": "application/vnd.cyclonedx+xml",
28+
"url": "https://logging.apache.org/cyclonedx/urn:cdx:dfa35519-9734-4259-bba1-3e825cf4be06/2.xml",
29+
"checksums": [
30+
{
31+
"type": "SHA256",
32+
"value": "75b81020b3917cb682b1a7605ade431e062f7a4c01a412f0b87543b6e995ad2a"
33+
}
34+
]
35+
}
36+
]
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"leaf_uuid": "1e7d13f3-4c65-40f1-a990-8b85079b2347",
3+
"uuid": "d750d933-38b2-46af-a8ad-71207ae2b56e",
4+
"collection_name": "Apache Log4j 2.23.1",
5+
"collection_version": "2",
6+
"release_date": "2024-03-06",
7+
"author": {
8+
"name": "John Doe",
9+
"email": "john@example.com",
10+
"organization": "The Apache Software Foundation"
11+
},
12+
"reason": "New Product Release",
13+
"artifacts": [
14+
{
15+
"type": "bom",
16+
"mime_type": "application/vnd.cyclonedx+xml",
17+
"url": "https://repo.maven.apache.org/maven2/org/apache/logging/log4j/log4j-bom/2.23.1/log4j-bom-2.23.1-cyclonedx.xml",
18+
"checksums": [
19+
{
20+
"type": "SHA1",
21+
"value": "7508931879d04ae497e683eb3abe15376e930c8b"
22+
}
23+
]
24+
},
25+
{
26+
"type": "vulnerability-assertion",
27+
"mime_type": "application/vnd.cyclonedx+xml",
28+
"url": "https://logging.apache.org/cyclonedx/urn:cdx:dfa35519-9734-4259-bba1-3e825cf4be06/2.xml",
29+
"checksums": [
30+
{
31+
"type": "SHA256",
32+
"value": "75b81020b3917cb682b1a7605ade431e062f7a4c01a412f0b87543b6e995ad2a"
33+
}
34+
]
35+
}
36+
]
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"leaf_uuid": "b0d30215-04f0-462f-84d4-68fcff437f5e",
3+
"uuid": "e697693d-2acf-42af-a0b9-6f85aa84ec10",
4+
"collection_name": "Apache Log4j 1.2.17",
5+
"collection_version": "1",
6+
"release_date": "2024-02-17",
7+
"author": {
8+
"name": "John Doe",
9+
"email": "john@example.com",
10+
"organization": "The Apache Software Foundation"
11+
},
12+
"reason": "New Product Release"
13+
}

examples/v1/leaf.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"timestamp": "2024-03-20T15:30:00Z",
3+
"page_start_index": 0,
4+
"page_size": 2147483647,
5+
"total_results": 2,
6+
"content": [
7+
{
8+
"product_uuid": "18736afd-7ac1-4b6b-b284-03495bf83289",
9+
"uuid": "b0d30215-04f0-462f-84d4-68fcff437f5e",
10+
"leaf_name": "Apache Log4j 1.2",
11+
"leaf_version": "1.2"
12+
},
13+
{
14+
"product_uuid": "96575f2d-ec70-445c-957e-543de92b70b3",
15+
"uuid": "1e7d13f3-4c65-40f1-a990-8b85079b2347",
16+
"leaf_name": "Apache Log4j 2.23",
17+
"leaf_version": "2.23"
18+
}
19+
]
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"product_uuid": "96575f2d-ec70-445c-957e-543de92b70b3",
3+
"uuid": "1e7d13f3-4c65-40f1-a990-8b85079b2347",
4+
"leaf_name": "Apache Log4j 2.23",
5+
"leaf_version": "2.23",
6+
"cle": [
7+
{
8+
"type": "generalAvailability",
9+
"effective": "2024-02-17",
10+
"ranges": [
11+
"vers:maven/>=2.23|<2.24"
12+
]
13+
},
14+
{
15+
"type": "endOfSupport",
16+
"effective": "2024-09-03",
17+
"ranges": [
18+
"vers:maven/>=2.23|<2.24"
19+
]
20+
}
21+
]
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"product_uuid": "18736afd-7ac1-4b6b-b284-03495bf83289",
3+
"uuid": "b0d30215-04f0-462f-84d4-68fcff437f5e",
4+
"leaf_name": "Apache Log4j 1.2",
5+
"leaf_version": "1.2",
6+
"cle": [
7+
{
8+
"type": "generalAvailability",
9+
"effective": "2002-05-01",
10+
"ranges": [
11+
"vers:maven/>=1.2|<1.3"
12+
]
13+
},
14+
{
15+
"type": "endOfSupport",
16+
"effective": "2015-08-15",
17+
"ranges": [
18+
"vers:maven/>=1.2|<1.3"
19+
]
20+
}
21+
]
22+
}

examples/v1/product.json

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"timestamp": "2024-03-20T15:30:00Z",
3+
"page_start_index": 0,
4+
"page_size": 2147483647,
5+
"total_results": 2,
6+
"content": [
7+
{
8+
"uuid": "18736afd-7ac1-4b6b-b284-03495bf83289",
9+
"product_name": "Apache Log4j 1",
10+
"identifiers": [
11+
{
12+
"type": "tei",
13+
"value": "urn:tei:dns:apache.org:logging-log4j1"
14+
},
15+
{
16+
"type": "purl",
17+
"value": "pkg:maven/log4j/log4j"
18+
},
19+
{
20+
"type": "cpe",
21+
"value": "cpe:2.3:a:apache:log4j:*:*:*:*:*:*:*:*"
22+
}
23+
]
24+
},
25+
{
26+
"uuid": "96575f2d-ec70-445c-957e-543de92b70b3",
27+
"product_name": "Apache Log4j 2",
28+
"identifiers": [
29+
{
30+
"type": "tei",
31+
"value": "urn:tei:dns:apache.org:logging-log4j2"
32+
},
33+
{
34+
"type": "purl",
35+
"value": "pkg:maven/org.apache.logging.log4j/log4j-api"
36+
},
37+
{
38+
"type": "purl",
39+
"value": "pkg:maven/org.apache.logging.log4j/log4j-core"
40+
},
41+
{
42+
"type": "purl",
43+
"value": "pkg:maven/org.apache.logging.log4j/log4j-layout-template-json"
44+
},
45+
{
46+
"type": "purl",
47+
"value": "pkg:maven/org.apache.logging.log4j/slf4j-to-log4j-api"
48+
},
49+
{
50+
"type": "purl",
51+
"value": "pkg:maven/org.apache.logging.log4j/jul-to-log4j-api"
52+
},
53+
{
54+
"type": "purl",
55+
"value": "pkg:maven/org.apache.logging.log4j/jpl-to-log4j-api"
56+
},
57+
{
58+
"type": "cpe",
59+
"value": "cpe:2.3:a:apache:log4j:*:*:*:*:*:*:*:*"
60+
}
61+
]
62+
}
63+
]
64+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
urn%3Auuid%3A18736afd-7ac1-4b6b-b284-03495bf83289.json
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
urn%3Auuid%3A96575f2d-ec70-445c-957e-543de92b70b3.json
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"uuid": "18736afd-7ac1-4b6b-b284-03495bf83289",
3+
"product_name": "Apache Log4j 1",
4+
"identifiers": [
5+
{
6+
"type": "tei",
7+
"value": "urn:tei:dns:apache.org:logging-log4j1"
8+
},
9+
{
10+
"type": "purl",
11+
"value": "pkg:maven/log4j/log4j"
12+
},
13+
{
14+
"type": "cpe",
15+
"value": "cpe:2.3:a:apache:log4j:*:*:*:*:*:*:*:*"
16+
}
17+
],
18+
"cle": [
19+
{
20+
"type": "generalAvailability",
21+
"effective": "2001-01-08",
22+
"ranges": [
23+
"vers:maven/>=1|<2"
24+
]
25+
},
26+
{
27+
"type": "endOfLife",
28+
"effective": "2015-08-15",
29+
"ranges": [
30+
"vers:maven/>=1|<2"
31+
]
32+
}
33+
]
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"uuid": "96575f2d-ec70-445c-957e-543de92b70b3",
3+
"product_name": "Apache Log4j 2",
4+
"identifiers": [
5+
{
6+
"type": "tei",
7+
"value": "urn:tei:dns:apache.org:logging-log4j2"
8+
},
9+
{
10+
"type": "purl",
11+
"value": "pkg:maven/org.apache.logging.log4j/log4j-api"
12+
},
13+
{
14+
"type": "purl",
15+
"value": "pkg:maven/org.apache.logging.log4j/log4j-core"
16+
},
17+
{
18+
"type": "purl",
19+
"value": "pkg:maven/org.apache.logging.log4j/log4j-layout-template-json"
20+
},
21+
{
22+
"type": "purl",
23+
"value": "pkg:maven/org.apache.logging.log4j/slf4j-to-log4j-api"
24+
},
25+
{
26+
"type": "purl",
27+
"value": "pkg:maven/org.apache.logging.log4j/jul-to-log4j-api"
28+
},
29+
{
30+
"type": "purl",
31+
"value": "pkg:maven/org.apache.logging.log4j/jpl-to-log4j-api"
32+
},
33+
{
34+
"type": "cpe",
35+
"value": "cpe:2.3:a:apache:log4j:*:*:*:*:*:*:*:*"
36+
}
37+
],
38+
"cle": [
39+
{
40+
"type": "generalAvailability",
41+
"effective": "2014-07-12",
42+
"ranges": [
43+
"vers:maven/>=2|<3"
44+
]
45+
}
46+
]
47+
}

0 commit comments

Comments
 (0)