Skip to content

Commit 42cab20

Browse files
authored
Apply black and markdownlint --fix (#885)
2 parents 9d0c264 + 49ad0e6 commit 42cab20

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+661
-277
lines changed

docs/adr/0012-ssvc-namespaces.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ consulted: @tschmidtb51
99
## Context and Problem Statement
1010

1111
We need to include decision points and other objects that are not directly
12-
defined by the SSVC project team. For example, CVSS vector elements are a
12+
defined by the SSVC project team. For example, CVSS vector elements are a
1313
rich source of structured data that can be used to inform SSVC decisions and
14-
modeled as SSVC decision point objects. However, the
15-
[FIRST CVSS SIG](https://www.first.org/cvss) owns the definition of CVSS vector
14+
modeled as SSVC decision point objects. However, the
15+
[FIRST CVSS SIG](https://www.first.org/cvss) owns the definition of CVSS vector
1616
elements. So we need a way to describe these objects in SSVC format
1717
without making them part of the SSVC specification.
1818

19-
2019
## Decision Drivers
2120

2221
- Need to include decision points based on data, objects, standards, and other
@@ -49,7 +48,7 @@ based on other sources).
4948
main project. We use the `cvss` namespace to contain CVSS vector elements.
5049

5150
**Unregistered namespaces** for objects that we do not create or maintain, but
52-
that others may want for their own use. Unregistered namespaces must start with
51+
that others may want for their own use. Unregistered namespaces must start with
5352
an `x_` prefix followed by a reverse domain name, such as `x_org.example`.
5453
Unregistered namespaces are intended for experimental or private use.
5554

@@ -61,10 +60,10 @@ Unregistered namespaces are intended for experimental or private use.
6160
register their namespace with the SSVC project.
6261

6362
**Namespace extensions** for objects that are derived from other objects in an
64-
registered or unregistered namespace. Extensions are not intended to be used to
63+
registered or unregistered namespace. Extensions are not intended to be used to
6564
introduce new objects, but rather to refine existing objects with additional data
6665
or semantics.
67-
Namespace extensions can be used for refining the meaning of decision point
66+
Namespace extensions can be used for refining the meaning of decision point
6867
values for a specific constituency, or adding additional nuance to
6968
interpretation of a decision point in a specific context.
7069

@@ -84,7 +83,6 @@ interpretation of a decision point in a specific context.
8483
- Facilitates language translation and localization of SSVC objects to specific
8584
constituencies
8685

87-
8886
#### Negative Consequences
8987

9088
- Registered namespaces must be managed and maintained
@@ -114,7 +112,6 @@ SSVC specification under our control and objects that were derived from other so
114112
- Bad, because it made it difficult to distinguish between SSVC project objects and
115113
objects based on specifications we neither created nor maintained
116114

117-
118115
<!-- This is an optional element. Feel free to remove. -->
119116
## More Information
120117

docs/reference/code/namespaces.md

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
We use namespaces in SSVC to organize the various components of the framework.
44
The bulk of our work is done in the `ssvc` namespace, which contains the core
5-
decision points for SSVC.
5+
decision points for SSVC.
66

77
!!! question "Why does SSVC need namespaces?"
88

@@ -54,7 +54,6 @@ subgraph base_ns[Base Namespace]
5454
end
5555
```
5656

57-
5857
!!! info inline end "Current Registered Namespaces"
5958

6059
The SSVC project currently has a set of registered namespaces that are
@@ -76,7 +75,7 @@ A list of the current registered namespaces can be found in the sidebar.
7675

7776
Registered namespaces are intended to be used as follows:
7877

79-
- Objects in the `ssvc` namespace are managed by the SSVC
78+
- Objects in the `ssvc` namespace are managed by the SSVC
8079
project team. We have complete control over these ones.
8180
- Objects in other explicitly registered namespaces are provided for convenience,
8281
but the SSVC team is not responsible for modifying the content or semantics of
@@ -112,8 +111,6 @@ Registered namespaces are intended to be used as follows:
112111
Suggestions for changes to the CVSS specifications should be directed to the
113112
[FIRST CVSS Special Interest Group](https://www.first.org/cvss/) (SIG).
114113

115-
116-
117114
!!! example "Potential Standards-based namespaces"
118115

119116
We may in the future add namespaces when needed to reflect different standards
@@ -140,8 +137,8 @@ we expect that this will rarely lead to conflicts in practice.
140137
- Unregistered namespaces must use the `x_` prefix.
141138
- Following the `x_` prefix, unregistered namespaces must use reverse domain name notation of a domain under their control to ensure uniqueness.
142139
- Aside from the required `x_` prefix, unregistered namespaces must contain only alphanumeric characters, dots (`.`), and dashes (`-`).
143-
- For any domain using other characters, DNS Punycode must be used
144140

141+
- For any domain using other characters, DNS Punycode must be used
145142

146143
!!! warning "Namespace Conflicts"
147144

@@ -150,7 +147,6 @@ we expect that this will rarely lead to conflicts in practice.
150147
`x_example.test`, and there are no guarantees of global uniqueness for the
151148
decision points in the `x_example.test` namespace.
152149

153-
154150
!!! tip "Test Namespace"
155151

156152
The `x_example.test` namespace is used for testing purposes and is not intended for production use.
@@ -198,6 +194,7 @@ A single fragment identifier (`#`) may be included in an extension segment, but
198194
Fragment segments can be used to indicate a specific interpretation or context for the extension.
199195
Note: Without a fragment segment, all decision points of an organization fall into one bucket, which is in most cases not intended. Therefore, the use of a fragment segment is recommended.
200196
The following diagram illustrates the structure of namespace extensions:
197+
201198
```mermaid
202199
---
203200
title: Namespace Extensions
@@ -256,7 +253,6 @@ base_ns -->|/| first
256253
available in the default language (`en-US`), and (b) that this extension has
257254
been translated into German (Germany).
258255

259-
260256
!!! example "Use of fragment identifiers and language tags"
261257

262258
Imagine an Information Sharing and Analysis Organization (ISAO) `isao.example`
@@ -287,9 +283,9 @@ base_ns -->|/| first
287283

288284
### Usage Suggestions
289285

290-
Although we reserved the first segment of the extension for language tags,
286+
Although we reserved the first segment of the extension for language tags,
291287
there are scenarios where it may be appropriate to use a language tag in a later
292-
segment of the extension.
288+
segment of the extension.
293289

294290
!!! tip "Use BCP-47 Language Tags"
295291

@@ -314,7 +310,6 @@ segment of the extension.
314310
For example, if your organization is `example.com`, you might use an extension
315311
like `ssvc//com.example#extension`.
316312

317-
318313
## Technical requirements
319314

320315
The following technical requirements are enforced for SSVC namespaces,
@@ -350,17 +345,15 @@ based on the implementation in `src/ssvc/namespaces.py` and the NS_PATTERN regul
350345
- If any extension segments are present, the following rules apply:
351346
- The first extension segment must be a valid BCP-47 language tag or empty (i.e., `//`).
352347
- Subsequent extension segments:
353-
- must start with a letter (upper or lowercase)
354-
- may contain letters, numbers, dots (`.`), hyphens (`-`), and at most one hash (`#`)
355-
- must not contain consecutive dots or hyphens (no `..`, `--`, `.-`, `-.`, `---`, etc.)
356-
- if a hash is present, it separates the main part from an optional fragment part
357-
- are separated by single forward slashes (`/`)
348+
- must start with a letter (upper or lowercase)
349+
- may contain letters, numbers, dots (`.`), hyphens (`-`), and at most one hash (`#`)
350+
- must not contain consecutive dots or hyphens (no `..`, `--`, `.-`, `-.`, `---`, etc.)
351+
- if a hash is present, it separates the main part from an optional fragment part
352+
- are separated by single forward slashes (`/`)
358353
- Multiple extension segments are allowed
359354

360-
361355
## The `ssvc.namespaces` module
362356

363357
The `ssvc.namespaces` module provides a way to access and use these namespaces.
364358

365359
::: ssvc.namespaces
366-

src/ssvc/_mixins.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@
2525
from datetime import datetime, timezone
2626
from typing import Any, Optional
2727

28-
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
28+
from pydantic import (
29+
BaseModel,
30+
ConfigDict,
31+
Field,
32+
field_validator,
33+
model_validator,
34+
)
2935
from semver import Version
3036

3137
from ssvc.namespaces import NameSpace
@@ -64,7 +70,9 @@ class _SchemaVersioned(BaseModel):
6470
Mixin class for version
6571
"""
6672

67-
schemaVersion: str = Field(..., description="Schema version of the SSVC object")
73+
schemaVersion: str = Field(
74+
..., description="Schema version of the SSVC object"
75+
)
6876

6977
@model_validator(mode="before")
7078
def set_schema_version(cls, data):
@@ -118,7 +126,16 @@ class _Keyed(BaseModel):
118126
"(`T*` is explicitly grandfathered in as a valid key, but should not be used for new objects.)",
119127
pattern=r"^(([a-zA-Z0-9])|([a-zA-Z0-9][a-zA-Z0-9_]*[a-zA-Z0-9])|(T\*))$",
120128
min_length=1,
121-
examples=["E", "A", "SI", "L", "M", "H", "Mixed_case_OK", "alph4num3ric"],
129+
examples=[
130+
"E",
131+
"A",
132+
"SI",
133+
"L",
134+
"M",
135+
"H",
136+
"Mixed_case_OK",
137+
"alph4num3ric",
138+
],
122139
)
123140

124141

src/ssvc/csv_analyzer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ def _imp_df(column_names: list, importances: list) -> pd.DataFrame:
104104
a dataframe of feature importances
105105
"""
106106
df = (
107-
pd.DataFrame({"feature": column_names, "feature_importance": importances})
107+
pd.DataFrame(
108+
{"feature": column_names, "feature_importance": importances}
109+
)
108110
.sort_values("feature_importance", ascending=False)
109111
.reset_index(drop=True)
110112
)
@@ -193,7 +195,9 @@ def _perm_feat_imp(model, x, y):
193195

194196
def _parse_args(args) -> argparse.Namespace:
195197
# parse command line
196-
parser = argparse.ArgumentParser(description="Analyze an SSVC tree csv file")
198+
parser = argparse.ArgumentParser(
199+
description="Analyze an SSVC tree csv file"
200+
)
197201
parser.add_argument(
198202
"csvfile", metavar="csvfile", type=str, help="the csv file to analyze"
199203
)

src/ssvc/decision_points/cvss/helpers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727

2828
from ssvc.decision_points.base import DecisionPointValue
2929
from ssvc.decision_points.cvss._not_defined import NOT_DEFINED_X
30-
from ssvc.decision_points.cvss.base import CvssDecisionPoint, CvssDecisionPoint as DecisionPoint
30+
from ssvc.decision_points.cvss.base import (
31+
CvssDecisionPoint,
32+
CvssDecisionPoint as DecisionPoint,
33+
)
3134

3235

3336
def _modify_3(dp: DecisionPoint):
@@ -94,7 +97,9 @@ def _modify_4(dp: DecisionPoint):
9497
for v in _dp_dict["values"]:
9598
if v["key"] == "N":
9699
v["name"] = "Negligible"
97-
v["description"] = v["description"].replace(" no ", " negligible ")
100+
v["description"] = v["description"].replace(
101+
" no ", " negligible "
102+
)
98103
# we need to bump the version for this change
99104
version = _dp_dict["version"]
100105
ver = semver.Version.parse(version)

src/ssvc/decision_points/cvss/modified/modified_subsequent_availability_impact.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ def main():
3737
from ssvc.decision_points.helpers import print_versions_and_diffs
3838

3939
print_versions_and_diffs(VERSIONS)
40-
print_versions_and_diffs([
41-
MSA_NoX,
42-
])
40+
print_versions_and_diffs(
41+
[
42+
MSA_NoX,
43+
]
44+
)
4345

4446

4547
if __name__ == "__main__":

src/ssvc/decision_points/helpers.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,33 +121,45 @@ def dp_diff(dp1: DecisionPoint, dp2: DecisionPoint) -> list[str]:
121121
major = True
122122

123123
for name in dp2_names.difference(dp1_names):
124-
diffs.append(f"(major or minor) {dp2.name} v{dp2.version} adds value {name}")
124+
diffs.append(
125+
f"(major or minor) {dp2.name} v{dp2.version} adds value {name}"
126+
)
125127
maybe_major = True
126128
maybe_minor = True
127129

128130
# did the value keys change?
129131
for name in intersection:
130-
v1 = {value["name"]: value["key"] for value in dp1.model_dump()["values"]}
132+
v1 = {
133+
value["name"]: value["key"] for value in dp1.model_dump()["values"]
134+
}
131135
v1 = v1[name]
132136

133-
v2 = {value["name"]: value["key"] for value in dp2.model_dump()["values"]}
137+
v2 = {
138+
value["name"]: value["key"] for value in dp2.model_dump()["values"]
139+
}
134140
v2 = v2[name]
135141

136142
if v1 != v2:
137-
diffs.append(f"(minor) {dp2.name} v{dp2.version} value {name} key changed")
143+
diffs.append(
144+
f"(minor) {dp2.name} v{dp2.version} value {name} key changed"
145+
)
138146
minor = True
139147
else:
140-
diffs.append(f"{dp2.name} v{dp2.version} value {name} key did not change")
148+
diffs.append(
149+
f"{dp2.name} v{dp2.version} value {name} key did not change"
150+
)
141151

142152
# did the value descriptions change?
143153
for name in intersection:
144154
v1 = {
145-
value["name"]: value["description"] for value in dp1.model_dump()["values"]
155+
value["name"]: value["description"]
156+
for value in dp1.model_dump()["values"]
146157
}
147158
v1 = v1[name]
148159

149160
v2 = {
150-
value["name"]: value["description"] for value in dp2.model_dump()["values"]
161+
value["name"]: value["description"]
162+
for value in dp2.model_dump()["values"]
151163
}
152164
v2 = v2[name]
153165

src/ssvc/decision_points/ssvc/mission_impact.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@
5252
description="Degradation of non-essential functions; chronic degradation would eventually harm essential functions",
5353
)
5454

55-
MI_NONE = DecisionPointValue(name="None", key="N", description="Little to no impact")
55+
MI_NONE = DecisionPointValue(
56+
name="None", key="N", description="Little to no impact"
57+
)
5658

5759
# combine MI_NONE and MI_NED into a single value
5860
DEGRADED = DecisionPointValue(

0 commit comments

Comments
 (0)