Repository navigation
Expand file tree
/
Copy path_inputs.py
More file actions
148 lines (117 loc) · 4.22 KB
/
Copy path_inputs.py
File metadata and controls
148 lines (117 loc) · 4.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
"""The facts the edge gathers and the model turns into a document."""
from __future__ import annotations
from dataclasses import dataclass
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from pathlib import PurePosixPath
from ._metadata import CoreMetadata
from ._types import Component, Dependency, OrganizationalEntity
@dataclass(frozen=True, slots=True, kw_only=True)
class RecordRow:
path: str
algorithm: str
digest: str
size: str
@dataclass(frozen=True, slots=True, kw_only=True)
class Interpreter:
name: str
version: str
implementation: str
@dataclass(frozen=True, slots=True, kw_only=True)
class InstalledDistribution:
name: str
metadata: CoreMetadata
files: list[RecordRow]
depends_on: list[str]
@dataclass(frozen=True, slots=True, kw_only=True)
class Revision:
commit: str
dirty: bool
@dataclass(frozen=True, slots=True, kw_only=True)
class BuildFacts:
epoch: int
epoch_from_environment: bool
revision: Revision | None
interpreter: Interpreter
distributions: list[InstalledDistribution]
@dataclass(frozen=True, slots=True, kw_only=True)
class Settings:
"""
The project's options, from ``[tool.python-sbom]``.
:param supplier: the organization that supplies the project, or ``None`` to name none
:param repository: the repository URL, or ``None`` to take the first ``Source``, ``Repository`` or ``GitHub``
project URL
:param default_branch: the branch in links to files in the repository when the build's commit is unknown or has
uncommitted changes
:param bundled_wheels: glob patterns, relative to the project directory, of wheels the project ships as data files
:param content_provider: one provider or an ordered tuple of providers, by entry point name or ``module:attribute``,
or ``None``
:param build_backend: the build backend ``python_sbom.backend`` wraps, as ``module`` or ``module:object``, or
``None``
"""
supplier: OrganizationalEntity | None
repository: str | None
default_branch: str
bundled_wheels: tuple[str, ...]
content_provider: str | tuple[str, ...] | None
build_backend: str | None
@dataclass(frozen=True, slots=True, kw_only=True)
class BundledWheel:
path: str
sha256: str
metadata_name: str
metadata: CoreMetadata
files: list[RecordRow]
vendored: list[tuple[str, CoreMetadata]]
@dataclass(frozen=True, slots=True, kw_only=True)
class BuildScript:
path: PurePosixPath
sha256: str
@dataclass(frozen=True, slots=True, kw_only=True)
class ArchiveTree:
# what an archive holds, read from the zip without unpacking it: each distribution's metadata and members by the
# directory that holds its .dist-info, "" for the project's own, the archive's own top-level files, the digest of
# every member but the bundled wheels, and those wheels
metadata: dict[str, CoreMetadata]
owned: dict[str, list[str]]
loose: list[str]
files: dict[str, RecordRow]
bundled: dict[str, BundledWheel]
@dataclass(frozen=True, slots=True, kw_only=True)
class Artifact:
# what one artifact, a wheel or an archive, puts in its SBOM; the provenance every artifact of the project shares is
# added around it
root: Component
components: list[Component]
dependencies: list[Dependency]
build_scripts: list[BuildScript]
version: str
sbom_file: str
scope: str
workflow: tuple[str, str]
license_file: str | None
copyright: str | None
@dataclass(frozen=True, slots=True, kw_only=True)
class WheelTree:
# what a built wheel holds, read from the wheel without unpacking it: its file name, its core metadata, the wheels
# it bundles and the SHA-256 of each other file in its sboms directory, by its path there; and
# what the project adds: the copyright line of its license files and the scripts that built it
name: str
metadata: CoreMetadata
copyright: str | None
bundled: list[BundledWheel]
build_scripts: list[BuildScript]
other_sboms: dict[str, str]
__all__ = [
"ArchiveTree",
"Artifact",
"BuildFacts",
"BuildScript",
"BundledWheel",
"InstalledDistribution",
"Interpreter",
"RecordRow",
"Revision",
"Settings",
"WheelTree",
]