smoke-sdk 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- smoke_sdk/__init__.py +6 -0
- smoke_sdk/client.py +267 -0
- smoke_sdk/py.typed +0 -0
- smoke_sdk/types.py +324 -0
- smoke_sdk/webhooks.py +35 -0
- smoke_sdk-0.1.0.dist-info/METADATA +95 -0
- smoke_sdk-0.1.0.dist-info/RECORD +9 -0
- smoke_sdk-0.1.0.dist-info/WHEEL +4 -0
- smoke_sdk-0.1.0.dist-info/licenses/LICENSE +202 -0
smoke_sdk/__init__.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"""Smoke SDK for Python: the public API v1 client and webhook signature verification."""
|
|
2
|
+
|
|
3
|
+
from .client import SmokeApiError, SmokeClient, __version__
|
|
4
|
+
from .webhooks import verify_webhook_signature
|
|
5
|
+
|
|
6
|
+
__all__ = ["SmokeApiError", "SmokeClient", "verify_webhook_signature", "__version__"]
|
smoke_sdk/client.py
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"""Client of the Smoke public API v1 (standard library only)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import random
|
|
7
|
+
import time
|
|
8
|
+
import urllib.error
|
|
9
|
+
import urllib.parse
|
|
10
|
+
import urllib.request
|
|
11
|
+
import uuid
|
|
12
|
+
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Tuple, Union, cast
|
|
13
|
+
|
|
14
|
+
from .types import (
|
|
15
|
+
Asset,
|
|
16
|
+
AssetPage,
|
|
17
|
+
ClientPage,
|
|
18
|
+
FindingDetail,
|
|
19
|
+
FindingPage,
|
|
20
|
+
MemberPage,
|
|
21
|
+
Project,
|
|
22
|
+
ProjectPage,
|
|
23
|
+
Snapshot,
|
|
24
|
+
Workspace,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
__version__ = "0.1.0"
|
|
28
|
+
RETRYABLE = {408, 429, 500, 502, 503, 504}
|
|
29
|
+
Content = Union[bytes, str]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class SmokeApiError(Exception):
|
|
33
|
+
"""An error answer of the API. ``code`` is stable (see the API guide)."""
|
|
34
|
+
|
|
35
|
+
def __init__(
|
|
36
|
+
self,
|
|
37
|
+
status: int,
|
|
38
|
+
code: str,
|
|
39
|
+
message: str,
|
|
40
|
+
details: Optional[List[Any]] = None,
|
|
41
|
+
request_id: Optional[str] = None,
|
|
42
|
+
) -> None:
|
|
43
|
+
super().__init__(f"{code}: {message}")
|
|
44
|
+
self.status = status
|
|
45
|
+
self.code = code
|
|
46
|
+
self.message = message
|
|
47
|
+
self.details = details or []
|
|
48
|
+
#: ``X-Smoke-Request-Id``: include it when reporting a problem.
|
|
49
|
+
self.request_id = request_id
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class SmokeClient:
|
|
53
|
+
"""Smoke public API v1.
|
|
54
|
+
|
|
55
|
+
``token`` is an integration or personal token (``smk_…``); ``base_url`` is
|
|
56
|
+
``https://api.<your Smoke domain>/v1``. 429, 5xx and network errors are retried with backoff
|
|
57
|
+
(honouring ``Retry-After``); uploads send the same ``Idempotency-Key`` on every attempt.
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
def __init__(
|
|
61
|
+
self,
|
|
62
|
+
token: str,
|
|
63
|
+
base_url: str,
|
|
64
|
+
max_retries: int = 3,
|
|
65
|
+
timeout: float = 30.0,
|
|
66
|
+
sleep: Callable[[float], None] = time.sleep,
|
|
67
|
+
) -> None:
|
|
68
|
+
if not token:
|
|
69
|
+
raise ValueError("token is required")
|
|
70
|
+
self._token = token
|
|
71
|
+
self._base = base_url.rstrip("/")
|
|
72
|
+
self._max_retries = max_retries
|
|
73
|
+
self._timeout = timeout
|
|
74
|
+
self._sleep = sleep
|
|
75
|
+
|
|
76
|
+
# ---- resources ------------------------------------------------------------------------
|
|
77
|
+
|
|
78
|
+
def workspace(self) -> Workspace:
|
|
79
|
+
return cast(Workspace, self._request("GET", "/workspace"))
|
|
80
|
+
|
|
81
|
+
def list_clients(self, cursor: Optional[str] = None, limit: Optional[int] = None) -> ClientPage:
|
|
82
|
+
return cast(ClientPage, self._request("GET", "/clients", {"cursor": cursor, "limit": limit}))
|
|
83
|
+
|
|
84
|
+
def list_projects(
|
|
85
|
+
self, client_id: Optional[str] = None, cursor: Optional[str] = None, limit: Optional[int] = None
|
|
86
|
+
) -> ProjectPage:
|
|
87
|
+
q = {"clientId": client_id, "cursor": cursor, "limit": limit}
|
|
88
|
+
return cast(ProjectPage, self._request("GET", "/projects", q))
|
|
89
|
+
|
|
90
|
+
def get_project(self, project_id: str) -> Project:
|
|
91
|
+
return cast(Project, self._request("GET", f"/projects/{_q(project_id)}"))
|
|
92
|
+
|
|
93
|
+
def list_assets(
|
|
94
|
+
self, project_id: Optional[str] = None, cursor: Optional[str] = None, limit: Optional[int] = None
|
|
95
|
+
) -> AssetPage:
|
|
96
|
+
q = {"projectId": project_id, "cursor": cursor, "limit": limit}
|
|
97
|
+
return cast(AssetPage, self._request("GET", "/assets", q))
|
|
98
|
+
|
|
99
|
+
def get_asset(self, asset_id: str) -> Asset:
|
|
100
|
+
return cast(Asset, self._request("GET", f"/assets/{_q(asset_id)}"))
|
|
101
|
+
|
|
102
|
+
def upload_inventory(
|
|
103
|
+
self,
|
|
104
|
+
asset_id: str,
|
|
105
|
+
files: Sequence[Tuple[str, Content]],
|
|
106
|
+
release: Optional[str] = None,
|
|
107
|
+
commit: Optional[str] = None,
|
|
108
|
+
environment: Optional[str] = None,
|
|
109
|
+
pipeline_url: Optional[str] = None,
|
|
110
|
+
idempotency_key: Optional[str] = None,
|
|
111
|
+
) -> Snapshot:
|
|
112
|
+
"""Uploads the asset's complete inventory: ``files`` are ``(path, content)`` pairs (every
|
|
113
|
+
lockfile, or one SBOM). Then ``wait_for_match(result["id"])``."""
|
|
114
|
+
fields = {"release": release, "commit": commit, "environment": environment, "pipelineUrl": pipeline_url}
|
|
115
|
+
body, ctype = _multipart(files, {k: v for k, v in fields.items() if v})
|
|
116
|
+
return cast(
|
|
117
|
+
Snapshot,
|
|
118
|
+
self._request(
|
|
119
|
+
"POST",
|
|
120
|
+
f"/assets/{_q(asset_id)}/inventory",
|
|
121
|
+
body=body,
|
|
122
|
+
content_type=ctype,
|
|
123
|
+
idempotency_key=idempotency_key or str(uuid.uuid4()),
|
|
124
|
+
),
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
def get_snapshot(self, snapshot_id: str) -> Snapshot:
|
|
128
|
+
return cast(Snapshot, self._request("GET", f"/snapshots/{_q(snapshot_id)}"))
|
|
129
|
+
|
|
130
|
+
def wait_for_match(self, snapshot_id: str, timeout: float = 300.0, interval: float = 5.0) -> Snapshot:
|
|
131
|
+
"""Polls until matching finished (``matched``, ``failed`` or ``superseded``)."""
|
|
132
|
+
deadline = time.monotonic() + timeout
|
|
133
|
+
while True:
|
|
134
|
+
s = self.get_snapshot(snapshot_id)
|
|
135
|
+
if s["match"]["status"] != "pending":
|
|
136
|
+
return s
|
|
137
|
+
if time.monotonic() > deadline:
|
|
138
|
+
raise TimeoutError(f"snapshot {snapshot_id} not matched in time")
|
|
139
|
+
self._sleep(interval)
|
|
140
|
+
|
|
141
|
+
def list_members(self, cursor: Optional[str] = None, limit: Optional[int] = None) -> MemberPage:
|
|
142
|
+
return cast(MemberPage, self._request("GET", "/members", {"cursor": cursor, "limit": limit}))
|
|
143
|
+
|
|
144
|
+
def list_findings(self, cursor: Optional[str] = None, **filters: Any) -> FindingPage:
|
|
145
|
+
"""Filters: ``projectId``, ``assetId``, ``clientId``, ``priority`` (``"P1,P2"``),
|
|
146
|
+
``status`` (comma-separated or ``"all"``), ``assigneeId``, ``contextLevel``
|
|
147
|
+
(``"act_now,schedule"``; also ``needs_context``, ``unrated``), ``updatedSince``, ``limit``."""
|
|
148
|
+
return cast(FindingPage, self._request("GET", "/findings", {**filters, "cursor": cursor}))
|
|
149
|
+
|
|
150
|
+
def iter_findings(self, **filters: Any) -> Iterator[Dict[str, Any]]:
|
|
151
|
+
"""Every finding matching the filters, page by page."""
|
|
152
|
+
cursor: Optional[str] = None
|
|
153
|
+
while True:
|
|
154
|
+
page = self.list_findings(cursor=cursor, **filters)
|
|
155
|
+
yield from cast(List[Dict[str, Any]], page["items"])
|
|
156
|
+
cursor = page["nextCursor"]
|
|
157
|
+
if not cursor:
|
|
158
|
+
return
|
|
159
|
+
|
|
160
|
+
def get_finding(self, finding_id: str) -> FindingDetail:
|
|
161
|
+
return cast(FindingDetail, self._request("GET", f"/findings/{_q(finding_id)}"))
|
|
162
|
+
|
|
163
|
+
def update_finding(self, finding_id: str, **patch: Any) -> FindingDetail:
|
|
164
|
+
"""``status``, ``reason``, ``note``, ``expiresAt``, ``until``, ``assigneeId`` (a member's
|
|
165
|
+
user id, or None to unassign)."""
|
|
166
|
+
return cast(
|
|
167
|
+
FindingDetail,
|
|
168
|
+
self._request("PATCH", f"/findings/{_q(finding_id)}", json_body=patch),
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
# ---- transport ------------------------------------------------------------------------
|
|
172
|
+
|
|
173
|
+
def _request(
|
|
174
|
+
self,
|
|
175
|
+
method: str,
|
|
176
|
+
path: str,
|
|
177
|
+
query: Optional[Dict[str, Any]] = None,
|
|
178
|
+
json_body: Any = None,
|
|
179
|
+
body: Optional[bytes] = None,
|
|
180
|
+
content_type: Optional[str] = None,
|
|
181
|
+
idempotency_key: Optional[str] = None,
|
|
182
|
+
) -> Any:
|
|
183
|
+
url = self._base + path
|
|
184
|
+
params = {k: str(v) for k, v in (query or {}).items() if v is not None and v != ""}
|
|
185
|
+
if params:
|
|
186
|
+
url += "?" + urllib.parse.urlencode(params)
|
|
187
|
+
headers = {
|
|
188
|
+
"Authorization": f"Bearer {self._token}",
|
|
189
|
+
"Accept": "application/json",
|
|
190
|
+
"User-Agent": f"smoke-sdk-python/{__version__}",
|
|
191
|
+
}
|
|
192
|
+
data = body
|
|
193
|
+
if json_body is not None:
|
|
194
|
+
data = json.dumps(json_body).encode()
|
|
195
|
+
headers["Content-Type"] = "application/json"
|
|
196
|
+
elif content_type:
|
|
197
|
+
headers["Content-Type"] = content_type
|
|
198
|
+
if idempotency_key:
|
|
199
|
+
headers["Idempotency-Key"] = idempotency_key
|
|
200
|
+
attempt = 0
|
|
201
|
+
while True:
|
|
202
|
+
req = urllib.request.Request(url, data=data, method=method, headers=headers)
|
|
203
|
+
try:
|
|
204
|
+
with urllib.request.urlopen(req, timeout=self._timeout) as res:
|
|
205
|
+
return json.loads(res.read() or b"{}")
|
|
206
|
+
except urllib.error.HTTPError as e:
|
|
207
|
+
raw = e.read()
|
|
208
|
+
if e.code in RETRYABLE and attempt < self._max_retries:
|
|
209
|
+
self._sleep(_retry_after(e.headers.get("Retry-After")) or _backoff(attempt))
|
|
210
|
+
attempt += 1
|
|
211
|
+
continue
|
|
212
|
+
try:
|
|
213
|
+
err = json.loads(raw or b"{}").get("error", {})
|
|
214
|
+
except ValueError:
|
|
215
|
+
err = {}
|
|
216
|
+
raise SmokeApiError(
|
|
217
|
+
e.code,
|
|
218
|
+
err.get("code") or f"HTTP_{e.code}",
|
|
219
|
+
err.get("message") or str(e.reason),
|
|
220
|
+
err.get("details"),
|
|
221
|
+
e.headers.get("X-Smoke-Request-Id"),
|
|
222
|
+
) from None
|
|
223
|
+
except (urllib.error.URLError, TimeoutError, ConnectionError):
|
|
224
|
+
if attempt >= self._max_retries:
|
|
225
|
+
raise
|
|
226
|
+
self._sleep(_backoff(attempt))
|
|
227
|
+
attempt += 1
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def _q(v: str) -> str:
|
|
231
|
+
return urllib.parse.quote(v, safe="")
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
def _retry_after(v: Optional[str]) -> Optional[float]:
|
|
235
|
+
try:
|
|
236
|
+
n = float(v) if v else 0
|
|
237
|
+
except ValueError:
|
|
238
|
+
return None
|
|
239
|
+
return n if n > 0 else None
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def _backoff(attempt: int) -> float:
|
|
243
|
+
return min(30.0, 0.5 * 2**attempt) * (0.5 + random.random() / 2)
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def _multipart(files: Sequence[Tuple[str, Content]], fields: Dict[str, str]) -> Tuple[bytes, str]:
|
|
247
|
+
boundary = "smoke-" + uuid.uuid4().hex
|
|
248
|
+
out = bytearray()
|
|
249
|
+
|
|
250
|
+
def part(headers: str, content: bytes) -> None:
|
|
251
|
+
out.extend(f"--{boundary}\r\n{headers}\r\n\r\n".encode())
|
|
252
|
+
out.extend(content)
|
|
253
|
+
out.extend(b"\r\n")
|
|
254
|
+
|
|
255
|
+
for path, content in files:
|
|
256
|
+
name = path.rsplit("/", 1)[-1].replace('"', "")
|
|
257
|
+
data = content.encode() if isinstance(content, str) else content
|
|
258
|
+
part(
|
|
259
|
+
f'Content-Disposition: form-data; name="files"; filename="{name}"\r\n'
|
|
260
|
+
"Content-Type: application/octet-stream",
|
|
261
|
+
data,
|
|
262
|
+
)
|
|
263
|
+
part('Content-Disposition: form-data; name="paths"', path.encode())
|
|
264
|
+
for k, v in fields.items():
|
|
265
|
+
part(f'Content-Disposition: form-data; name="{k}"', v.encode())
|
|
266
|
+
out.extend(f"--{boundary}--\r\n".encode())
|
|
267
|
+
return bytes(out), f"multipart/form-data; boundary={boundary}"
|
smoke_sdk/py.typed
ADDED
|
File without changes
|
smoke_sdk/types.py
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
"""Response types of the Smoke public API v1. Generated by tools/generate_types.py from
|
|
2
|
+
openapi.json: do not edit by hand. Within v1 fields are only added, never removed."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from typing import Any, Literal, Optional, TypedDict
|
|
7
|
+
|
|
8
|
+
class WorkspacePlan(TypedDict):
|
|
9
|
+
code: str
|
|
10
|
+
tier: Literal["free", "pro", "agency", "enterprise"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Workspace(TypedDict):
|
|
14
|
+
id: str
|
|
15
|
+
name: str
|
|
16
|
+
timeZone: str
|
|
17
|
+
plan: WorkspacePlan
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ClientPageItemsItem(TypedDict):
|
|
21
|
+
id: str
|
|
22
|
+
name: str
|
|
23
|
+
archived: bool
|
|
24
|
+
createdAt: str
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ClientPage(TypedDict):
|
|
28
|
+
items: list[ClientPageItemsItem]
|
|
29
|
+
nextCursor: Optional[str]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class ProjectPageItemsItemClient(TypedDict):
|
|
33
|
+
id: str
|
|
34
|
+
name: str
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class ProjectPageItemsItem(TypedDict):
|
|
38
|
+
id: str
|
|
39
|
+
name: str
|
|
40
|
+
client: Optional[ProjectPageItemsItemClient]
|
|
41
|
+
environment: Literal["production", "staging", "development"]
|
|
42
|
+
archived: bool
|
|
43
|
+
createdAt: str
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class ProjectPage(TypedDict):
|
|
47
|
+
items: list[ProjectPageItemsItem]
|
|
48
|
+
nextCursor: Optional[str]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class ProjectClient(TypedDict):
|
|
52
|
+
id: str
|
|
53
|
+
name: str
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class Project(TypedDict):
|
|
57
|
+
id: str
|
|
58
|
+
name: str
|
|
59
|
+
client: Optional[ProjectClient]
|
|
60
|
+
environment: Literal["production", "staging", "development"]
|
|
61
|
+
archived: bool
|
|
62
|
+
createdAt: str
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class AssetPageItemsItemProject(TypedDict):
|
|
66
|
+
id: str
|
|
67
|
+
name: str
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class AssetPageItemsItem(TypedDict):
|
|
71
|
+
id: str
|
|
72
|
+
name: str
|
|
73
|
+
kind: Literal["repository", "manifest_upload", "host", "container_image", "database"]
|
|
74
|
+
project: AssetPageItemsItemProject
|
|
75
|
+
archived: bool
|
|
76
|
+
inventoryUpdatedAt: Optional[str]
|
|
77
|
+
staleAt: Optional[str]
|
|
78
|
+
url: str
|
|
79
|
+
createdAt: str
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class AssetPage(TypedDict):
|
|
83
|
+
items: list[AssetPageItemsItem]
|
|
84
|
+
nextCursor: Optional[str]
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class AssetProject(TypedDict):
|
|
88
|
+
id: str
|
|
89
|
+
name: str
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class Asset(TypedDict):
|
|
93
|
+
id: str
|
|
94
|
+
name: str
|
|
95
|
+
kind: Literal["repository", "manifest_upload", "host", "container_image", "database"]
|
|
96
|
+
project: AssetProject
|
|
97
|
+
archived: bool
|
|
98
|
+
inventoryUpdatedAt: Optional[str]
|
|
99
|
+
staleAt: Optional[str]
|
|
100
|
+
url: str
|
|
101
|
+
createdAt: str
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class SnapshotRelease(TypedDict):
|
|
105
|
+
version: Optional[str]
|
|
106
|
+
commit: Optional[str]
|
|
107
|
+
environment: Optional[str]
|
|
108
|
+
pipelineUrl: Optional[str]
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class SnapshotMatch(TypedDict):
|
|
112
|
+
status: Literal["pending", "matched", "failed", "superseded"]
|
|
113
|
+
matchedAt: Optional[str]
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class SnapshotFindingsUnresolved(TypedDict):
|
|
117
|
+
p1: int
|
|
118
|
+
p2: int
|
|
119
|
+
p3: int
|
|
120
|
+
p4: int
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class SnapshotFindingsNew(TypedDict):
|
|
124
|
+
p1: int
|
|
125
|
+
p2: int
|
|
126
|
+
p3: int
|
|
127
|
+
p4: int
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
class SnapshotFindings(TypedDict):
|
|
131
|
+
unresolved: SnapshotFindingsUnresolved
|
|
132
|
+
new: SnapshotFindingsNew
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class Snapshot(TypedDict):
|
|
136
|
+
id: str
|
|
137
|
+
assetId: str
|
|
138
|
+
source: Literal["upload", "mcp", "repository", "collector", "ci", "api"]
|
|
139
|
+
release: Optional[SnapshotRelease]
|
|
140
|
+
createdAt: str
|
|
141
|
+
match: SnapshotMatch
|
|
142
|
+
findings: Optional[SnapshotFindings]
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class MemberPageItemsItem(TypedDict):
|
|
146
|
+
userId: str
|
|
147
|
+
email: str
|
|
148
|
+
displayName: Optional[str]
|
|
149
|
+
role: Literal["owner", "admin", "member"]
|
|
150
|
+
joinedAt: str
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
class MemberPage(TypedDict):
|
|
154
|
+
items: list[MemberPageItemsItem]
|
|
155
|
+
nextCursor: Optional[str]
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
class FindingPageItemsItemProject(TypedDict):
|
|
159
|
+
id: str
|
|
160
|
+
name: str
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
class FindingPageItemsItemClient(TypedDict):
|
|
164
|
+
id: str
|
|
165
|
+
name: str
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
class FindingPageItemsItemAsset(TypedDict):
|
|
169
|
+
id: str
|
|
170
|
+
name: str
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
class FindingPageItemsItemAdvisory(TypedDict):
|
|
174
|
+
id: str
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
class FindingPageItemsItemContextAssessment(TypedDict):
|
|
178
|
+
level: Optional[Literal["act_now", "schedule", "track"]]
|
|
179
|
+
status: Literal["assessed", "needs_context", "unrated", "none"]
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
class FindingPageItemsItem(TypedDict):
|
|
183
|
+
id: str
|
|
184
|
+
url: str
|
|
185
|
+
project: FindingPageItemsItemProject
|
|
186
|
+
client: Optional[FindingPageItemsItemClient]
|
|
187
|
+
asset: FindingPageItemsItemAsset
|
|
188
|
+
ecosystem: str
|
|
189
|
+
package: str
|
|
190
|
+
version: str
|
|
191
|
+
status: Literal["open", "in_progress", "pending_verification", "fixed", "mitigated", "ignored", "snoozed", "closed"]
|
|
192
|
+
statusChangedAt: str
|
|
193
|
+
priority: Literal["P1", "P2", "P3", "P4"]
|
|
194
|
+
priorityRule: str
|
|
195
|
+
severity: str
|
|
196
|
+
kev: bool
|
|
197
|
+
epss: Optional[float]
|
|
198
|
+
fixState: Literal["available", "partial", "blocked", "none", "unknown"]
|
|
199
|
+
advisory: Optional[FindingPageItemsItemAdvisory]
|
|
200
|
+
advisoryCount: int
|
|
201
|
+
assigneeUserId: Optional[str]
|
|
202
|
+
slaDueAt: str
|
|
203
|
+
slaState: Optional[Literal["on_track", "due_soon", "overdue", "met"]]
|
|
204
|
+
firstSeenAt: str
|
|
205
|
+
firstSeenRelease: Optional[str]
|
|
206
|
+
fixedAt: Optional[str]
|
|
207
|
+
fixedRelease: Optional[str]
|
|
208
|
+
needsCheck: bool
|
|
209
|
+
contextAssessment: Optional[FindingPageItemsItemContextAssessment]
|
|
210
|
+
updatedAt: str
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
class FindingPage(TypedDict):
|
|
214
|
+
items: list[FindingPageItemsItem]
|
|
215
|
+
nextCursor: Optional[str]
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
class FindingDetailProject(TypedDict):
|
|
219
|
+
id: str
|
|
220
|
+
name: str
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
class FindingDetailClient(TypedDict):
|
|
224
|
+
id: str
|
|
225
|
+
name: str
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
class FindingDetailAsset(TypedDict):
|
|
229
|
+
id: str
|
|
230
|
+
name: str
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
class FindingDetailAdvisory(TypedDict):
|
|
234
|
+
id: str
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
class FindingDetailContextAssessmentDecisive(TypedDict):
|
|
238
|
+
advisoryId: str
|
|
239
|
+
exploitation: Literal["active", "likely", "none"]
|
|
240
|
+
exploitationSource: Optional[Literal["kev", "manual", "epss"]]
|
|
241
|
+
attackPath: Optional[Literal["network", "network_interaction", "adjacent", "local"]]
|
|
242
|
+
reachable: Optional[bool]
|
|
243
|
+
rule: Literal["matrix", "distro_unimportant", "kernel_not_running"]
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
class FindingDetailContextAssessmentCounts(TypedDict):
|
|
247
|
+
act_now: int
|
|
248
|
+
schedule: int
|
|
249
|
+
track: int
|
|
250
|
+
unrated: int
|
|
251
|
+
needs_context: int
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
class FindingDetailContextAssessment(TypedDict):
|
|
255
|
+
level: Optional[Literal["act_now", "schedule", "track"]]
|
|
256
|
+
status: Literal["assessed", "needs_context", "unrated", "none"]
|
|
257
|
+
decisive: Optional[FindingDetailContextAssessmentDecisive]
|
|
258
|
+
counts: FindingDetailContextAssessmentCounts
|
|
259
|
+
missingQuestions: list[Literal["reach", "input"]]
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
class FindingDetailAdvisoriesItemSeverity(TypedDict):
|
|
263
|
+
level: str
|
|
264
|
+
score: Optional[float]
|
|
265
|
+
vector: Optional[str]
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
FindingDetailAdvisoriesItemPrerequisiteExplanation = TypedDict(
|
|
269
|
+
"FindingDetailAdvisoriesItemPrerequisiteExplanation",
|
|
270
|
+
{
|
|
271
|
+
"en": str,
|
|
272
|
+
"zh-TW": str,
|
|
273
|
+
},
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
class FindingDetailAdvisoriesItemPrerequisite(TypedDict):
|
|
278
|
+
explanation: FindingDetailAdvisoriesItemPrerequisiteExplanation
|
|
279
|
+
sources: list[str]
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
class FindingDetailAdvisoriesItem(TypedDict):
|
|
283
|
+
id: str
|
|
284
|
+
aliases: list[str]
|
|
285
|
+
cveIds: list[str]
|
|
286
|
+
severity: FindingDetailAdvisoriesItemSeverity
|
|
287
|
+
kev: bool
|
|
288
|
+
epss: Optional[float]
|
|
289
|
+
withdrawn: bool
|
|
290
|
+
prerequisite: Optional[FindingDetailAdvisoriesItemPrerequisite]
|
|
291
|
+
decision: Optional[Literal["affected", "not_affected"]]
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
class FindingDetail(TypedDict):
|
|
295
|
+
id: str
|
|
296
|
+
url: str
|
|
297
|
+
project: FindingDetailProject
|
|
298
|
+
client: Optional[FindingDetailClient]
|
|
299
|
+
asset: FindingDetailAsset
|
|
300
|
+
ecosystem: str
|
|
301
|
+
package: str
|
|
302
|
+
version: str
|
|
303
|
+
status: Literal["open", "in_progress", "pending_verification", "fixed", "mitigated", "ignored", "snoozed", "closed"]
|
|
304
|
+
statusChangedAt: str
|
|
305
|
+
priority: Literal["P1", "P2", "P3", "P4"]
|
|
306
|
+
priorityRule: str
|
|
307
|
+
severity: str
|
|
308
|
+
kev: bool
|
|
309
|
+
epss: Optional[float]
|
|
310
|
+
fixState: Literal["available", "partial", "blocked", "none", "unknown"]
|
|
311
|
+
advisory: Optional[FindingDetailAdvisory]
|
|
312
|
+
advisoryCount: int
|
|
313
|
+
assigneeUserId: Optional[str]
|
|
314
|
+
slaDueAt: str
|
|
315
|
+
slaState: Optional[Literal["on_track", "due_soon", "overdue", "met"]]
|
|
316
|
+
firstSeenAt: str
|
|
317
|
+
firstSeenRelease: Optional[str]
|
|
318
|
+
fixedAt: Optional[str]
|
|
319
|
+
fixedRelease: Optional[str]
|
|
320
|
+
needsCheck: bool
|
|
321
|
+
contextAssessment: FindingDetailContextAssessment
|
|
322
|
+
updatedAt: str
|
|
323
|
+
advisories: list[FindingDetailAdvisoriesItem]
|
|
324
|
+
fixVersions: list[str]
|
smoke_sdk/webhooks.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Smoke webhook signature verification (FR-NOT-14)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import hashlib
|
|
6
|
+
import hmac
|
|
7
|
+
import time
|
|
8
|
+
from typing import Optional, Union
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def verify_webhook_signature(
|
|
12
|
+
raw_body: Union[bytes, str],
|
|
13
|
+
header: Optional[str],
|
|
14
|
+
secret: str,
|
|
15
|
+
tolerance_seconds: int = 300,
|
|
16
|
+
now: Optional[float] = None,
|
|
17
|
+
) -> bool:
|
|
18
|
+
"""Checks ``X-Smoke-Signature`` (``t=<unix seconds>,v1=<hex>[,v1=<hex>]``).
|
|
19
|
+
|
|
20
|
+
The signature is HMAC-SHA256 with the signing secret over ``<t>.<raw body>``; during a secret
|
|
21
|
+
rotation there are two ``v1`` values and either may match. ``t`` must be within
|
|
22
|
+
``tolerance_seconds`` of now. Pass the raw body exactly as received, before JSON parsing.
|
|
23
|
+
"""
|
|
24
|
+
if not header:
|
|
25
|
+
return False
|
|
26
|
+
parts = [p.strip() for p in header.split(",")]
|
|
27
|
+
t = next((p[2:] for p in parts if p.startswith("t=")), "")
|
|
28
|
+
if not t.isdigit():
|
|
29
|
+
return False
|
|
30
|
+
current = time.time() if now is None else now
|
|
31
|
+
if abs(current - int(t)) > tolerance_seconds:
|
|
32
|
+
return False
|
|
33
|
+
body = raw_body.encode() if isinstance(raw_body, str) else raw_body
|
|
34
|
+
expected = hmac.new(secret.encode(), t.encode() + b"." + body, hashlib.sha256).hexdigest()
|
|
35
|
+
return any(hmac.compare_digest(p[3:], expected) for p in parts if p.startswith("v1="))
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: smoke-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for the Smoke public API v1 and webhook signatures
|
|
5
|
+
Project-URL: Homepage, https://github.com/Aircraft-IT/smoke-sdk-python
|
|
6
|
+
Project-URL: Source, https://github.com/Aircraft-IT/smoke-sdk-python
|
|
7
|
+
Project-URL: Issues, https://github.com/Aircraft-IT/smoke-sdk-python/issues
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Typing :: Typed
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# Smoke SDK for Python
|
|
17
|
+
|
|
18
|
+
Client for the Smoke public API v1 and helper to verify Smoke webhook signatures. Python 3.9 or
|
|
19
|
+
later; standard library only.
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
pip install smoke-sdk
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
Create an **integration token** (Admins, after turning on *API and webhooks* in the workspace
|
|
28
|
+
settings) or a personal token on the API tokens page. Keep it in a secret store, never in code.
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
import os
|
|
32
|
+
from smoke_sdk import SmokeClient
|
|
33
|
+
|
|
34
|
+
smoke = SmokeClient(os.environ["SMOKE_TOKEN"], "https://api.<your Smoke domain>/v1")
|
|
35
|
+
|
|
36
|
+
# Every P1 and P2 finding that still needs work, page by page.
|
|
37
|
+
for f in smoke.iter_findings(priority="P1,P2", status="open,in_progress"):
|
|
38
|
+
print(f["priority"], f["package"], f["version"], f["url"])
|
|
39
|
+
|
|
40
|
+
# Assign one to a member (user id from smoke.list_members()).
|
|
41
|
+
smoke.update_finding(finding_id, status="in_progress", assigneeId=user_id)
|
|
42
|
+
|
|
43
|
+
# Upload the inventory at every release, then wait for the result.
|
|
44
|
+
with open("package-lock.json", "rb") as fh:
|
|
45
|
+
snap = smoke.upload_inventory(
|
|
46
|
+
asset_id, [("package-lock.json", fh.read())], release="v1.4.2", commit=os.environ["GIT_SHA"]
|
|
47
|
+
)
|
|
48
|
+
done = smoke.wait_for_match(snap["id"])
|
|
49
|
+
if (done["findings"] or {}).get("unresolved", {}).get("p1", 0) > 0:
|
|
50
|
+
raise SystemExit(1)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Retries: 429, 5xx and network errors are retried up to 3 times with backoff, honouring
|
|
54
|
+
`Retry-After`; uploads send the same `Idempotency-Key` on every attempt. Errors are raised as
|
|
55
|
+
`SmokeApiError` with `status`, `code` (stable, see the API guide), `details` and `request_id`.
|
|
56
|
+
|
|
57
|
+
## Webhooks
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from smoke_sdk import verify_webhook_signature
|
|
61
|
+
|
|
62
|
+
# Flask: request.get_data() is the raw body.
|
|
63
|
+
@app.post("/smoke")
|
|
64
|
+
def smoke_webhook():
|
|
65
|
+
if not verify_webhook_signature(
|
|
66
|
+
request.get_data(), request.headers.get("X-Smoke-Signature"), os.environ["SMOKE_WEBHOOK_SECRET"]
|
|
67
|
+
):
|
|
68
|
+
return "", 401
|
|
69
|
+
event = request.get_json()
|
|
70
|
+
# Deduplicate by event["id"] (X-Smoke-Event-Id): a resent event keeps its id.
|
|
71
|
+
return "", 204
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Versions
|
|
75
|
+
|
|
76
|
+
This SDK follows semver and targets API `v1`, which only changes additively. `smoke_sdk/types.py`
|
|
77
|
+
is generated from `openapi.json` (`python3 tools/generate_types.py`), a copy of the public API
|
|
78
|
+
document (`https://api.<domain>/v1/openapi.json`); a test checks they agree.
|
|
79
|
+
|
|
80
|
+
## Source and releases
|
|
81
|
+
|
|
82
|
+
This repository is published at <https://github.com/Aircraft-IT/smoke-sdk-python> when a version
|
|
83
|
+
is released: each release is a tag `v<version>` on `main`, and pushing it runs
|
|
84
|
+
[the publish workflow](.github/workflows/publish.yml), which tests, builds and publishes the
|
|
85
|
+
package to PyPI through trusted publishing, with attestations. On pypi.org each file shows the
|
|
86
|
+
commit and workflow it was built from. Development happens in Smoke's own repository, so `main`
|
|
87
|
+
here moves only at releases.
|
|
88
|
+
|
|
89
|
+
Issues are welcome. Pull requests are not merged directly; a change we take is made in the
|
|
90
|
+
development repository and appears here with the next release. Contributions are under the
|
|
91
|
+
Apache License 2.0, like the rest of the repository.
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
Apache-2.0
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
smoke_sdk/__init__.py,sha256=z1X64BNQAKQ-8LP_Bb_4ELepr9nN8WdQhQUtyNifYKQ,284
|
|
2
|
+
smoke_sdk/client.py,sha256=4159yfPHajOLO6ShCLVKxY_SEbkK9Kw5F3IfK95Oyl8,10189
|
|
3
|
+
smoke_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
smoke_sdk/types.py,sha256=pHt2x6wgHKYaHeQVLn7xCsjE7Ogvlcg7mqjBlHyWmCw,7801
|
|
5
|
+
smoke_sdk/webhooks.py,sha256=YyrNVC85W_R0dZNJX4IpRneNPxZ6sSt9PMGG57Z0YNY,1297
|
|
6
|
+
smoke_sdk-0.1.0.dist-info/METADATA,sha256=KcZpMCxNnd3ISC-62HYlCtq5syf-qOSLWw6YW49R7kk,3650
|
|
7
|
+
smoke_sdk-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
8
|
+
smoke_sdk-0.1.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
9
|
+
smoke_sdk-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|