dockerfile-analyzer 0.1.0__tar.gz
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.
- dockerfile_analyzer-0.1.0/.github/workflows/CI.yml +181 -0
- dockerfile_analyzer-0.1.0/.gitignore +72 -0
- dockerfile_analyzer-0.1.0/Cargo.lock +250 -0
- dockerfile_analyzer-0.1.0/Cargo.toml +17 -0
- dockerfile_analyzer-0.1.0/LICENSE +21 -0
- dockerfile_analyzer-0.1.0/PKG-INFO +8 -0
- dockerfile_analyzer-0.1.0/README.md +5 -0
- dockerfile_analyzer-0.1.0/dockerfile_analyzer.pyi +85 -0
- dockerfile_analyzer-0.1.0/example.py +19 -0
- dockerfile_analyzer-0.1.0/py.typed +0 -0
- dockerfile_analyzer-0.1.0/pyproject.toml +15 -0
- dockerfile_analyzer-0.1.0/src/analyzer.rs +1510 -0
- dockerfile_analyzer-0.1.0/src/constants.rs +19 -0
- dockerfile_analyzer-0.1.0/src/lib.rs +49 -0
- dockerfile_analyzer-0.1.0/src/models.rs +269 -0
- dockerfile_analyzer-0.1.0/src/parse_utils.rs +571 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# This file is autogenerated by maturin v1.9.3
|
|
2
|
+
# To update, run
|
|
3
|
+
#
|
|
4
|
+
# maturin generate-ci github
|
|
5
|
+
#
|
|
6
|
+
name: CI
|
|
7
|
+
|
|
8
|
+
on:
|
|
9
|
+
push:
|
|
10
|
+
branches:
|
|
11
|
+
- main
|
|
12
|
+
- master
|
|
13
|
+
tags:
|
|
14
|
+
- '*'
|
|
15
|
+
pull_request:
|
|
16
|
+
workflow_dispatch:
|
|
17
|
+
|
|
18
|
+
permissions:
|
|
19
|
+
contents: read
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
linux:
|
|
23
|
+
runs-on: ${{ matrix.platform.runner }}
|
|
24
|
+
strategy:
|
|
25
|
+
matrix:
|
|
26
|
+
platform:
|
|
27
|
+
- runner: ubuntu-22.04
|
|
28
|
+
target: x86_64
|
|
29
|
+
- runner: ubuntu-22.04
|
|
30
|
+
target: x86
|
|
31
|
+
- runner: ubuntu-22.04
|
|
32
|
+
target: aarch64
|
|
33
|
+
- runner: ubuntu-22.04
|
|
34
|
+
target: armv7
|
|
35
|
+
- runner: ubuntu-22.04
|
|
36
|
+
target: s390x
|
|
37
|
+
- runner: ubuntu-22.04
|
|
38
|
+
target: ppc64le
|
|
39
|
+
steps:
|
|
40
|
+
- uses: actions/checkout@v4
|
|
41
|
+
- uses: actions/setup-python@v5
|
|
42
|
+
with:
|
|
43
|
+
python-version: 3.x
|
|
44
|
+
- name: Build wheels
|
|
45
|
+
uses: PyO3/maturin-action@v1
|
|
46
|
+
with:
|
|
47
|
+
target: ${{ matrix.platform.target }}
|
|
48
|
+
args: --release --out dist --find-interpreter
|
|
49
|
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
50
|
+
manylinux: auto
|
|
51
|
+
- name: Upload wheels
|
|
52
|
+
uses: actions/upload-artifact@v4
|
|
53
|
+
with:
|
|
54
|
+
name: wheels-linux-${{ matrix.platform.target }}
|
|
55
|
+
path: dist
|
|
56
|
+
|
|
57
|
+
musllinux:
|
|
58
|
+
runs-on: ${{ matrix.platform.runner }}
|
|
59
|
+
strategy:
|
|
60
|
+
matrix:
|
|
61
|
+
platform:
|
|
62
|
+
- runner: ubuntu-22.04
|
|
63
|
+
target: x86_64
|
|
64
|
+
- runner: ubuntu-22.04
|
|
65
|
+
target: x86
|
|
66
|
+
- runner: ubuntu-22.04
|
|
67
|
+
target: aarch64
|
|
68
|
+
- runner: ubuntu-22.04
|
|
69
|
+
target: armv7
|
|
70
|
+
steps:
|
|
71
|
+
- uses: actions/checkout@v4
|
|
72
|
+
- uses: actions/setup-python@v5
|
|
73
|
+
with:
|
|
74
|
+
python-version: 3.x
|
|
75
|
+
- name: Build wheels
|
|
76
|
+
uses: PyO3/maturin-action@v1
|
|
77
|
+
with:
|
|
78
|
+
target: ${{ matrix.platform.target }}
|
|
79
|
+
args: --release --out dist --find-interpreter
|
|
80
|
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
81
|
+
manylinux: musllinux_1_2
|
|
82
|
+
- name: Upload wheels
|
|
83
|
+
uses: actions/upload-artifact@v4
|
|
84
|
+
with:
|
|
85
|
+
name: wheels-musllinux-${{ matrix.platform.target }}
|
|
86
|
+
path: dist
|
|
87
|
+
|
|
88
|
+
windows:
|
|
89
|
+
runs-on: ${{ matrix.platform.runner }}
|
|
90
|
+
strategy:
|
|
91
|
+
matrix:
|
|
92
|
+
platform:
|
|
93
|
+
- runner: windows-latest
|
|
94
|
+
target: x64
|
|
95
|
+
- runner: windows-latest
|
|
96
|
+
target: x86
|
|
97
|
+
steps:
|
|
98
|
+
- uses: actions/checkout@v4
|
|
99
|
+
- uses: actions/setup-python@v5
|
|
100
|
+
with:
|
|
101
|
+
python-version: 3.x
|
|
102
|
+
architecture: ${{ matrix.platform.target }}
|
|
103
|
+
- name: Build wheels
|
|
104
|
+
uses: PyO3/maturin-action@v1
|
|
105
|
+
with:
|
|
106
|
+
target: ${{ matrix.platform.target }}
|
|
107
|
+
args: --release --out dist --find-interpreter
|
|
108
|
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
109
|
+
- name: Upload wheels
|
|
110
|
+
uses: actions/upload-artifact@v4
|
|
111
|
+
with:
|
|
112
|
+
name: wheels-windows-${{ matrix.platform.target }}
|
|
113
|
+
path: dist
|
|
114
|
+
|
|
115
|
+
macos:
|
|
116
|
+
runs-on: ${{ matrix.platform.runner }}
|
|
117
|
+
strategy:
|
|
118
|
+
matrix:
|
|
119
|
+
platform:
|
|
120
|
+
- runner: macos-13
|
|
121
|
+
target: x86_64
|
|
122
|
+
- runner: macos-14
|
|
123
|
+
target: aarch64
|
|
124
|
+
steps:
|
|
125
|
+
- uses: actions/checkout@v4
|
|
126
|
+
- uses: actions/setup-python@v5
|
|
127
|
+
with:
|
|
128
|
+
python-version: 3.x
|
|
129
|
+
- name: Build wheels
|
|
130
|
+
uses: PyO3/maturin-action@v1
|
|
131
|
+
with:
|
|
132
|
+
target: ${{ matrix.platform.target }}
|
|
133
|
+
args: --release --out dist --find-interpreter
|
|
134
|
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
135
|
+
- name: Upload wheels
|
|
136
|
+
uses: actions/upload-artifact@v4
|
|
137
|
+
with:
|
|
138
|
+
name: wheels-macos-${{ matrix.platform.target }}
|
|
139
|
+
path: dist
|
|
140
|
+
|
|
141
|
+
sdist:
|
|
142
|
+
runs-on: ubuntu-latest
|
|
143
|
+
steps:
|
|
144
|
+
- uses: actions/checkout@v4
|
|
145
|
+
- name: Build sdist
|
|
146
|
+
uses: PyO3/maturin-action@v1
|
|
147
|
+
with:
|
|
148
|
+
command: sdist
|
|
149
|
+
args: --out dist
|
|
150
|
+
- name: Upload sdist
|
|
151
|
+
uses: actions/upload-artifact@v4
|
|
152
|
+
with:
|
|
153
|
+
name: wheels-sdist
|
|
154
|
+
path: dist
|
|
155
|
+
|
|
156
|
+
release:
|
|
157
|
+
name: Release
|
|
158
|
+
runs-on: ubuntu-latest
|
|
159
|
+
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
|
|
160
|
+
needs: [linux, musllinux, windows, macos, sdist]
|
|
161
|
+
permissions:
|
|
162
|
+
# Use to sign the release artifacts
|
|
163
|
+
id-token: write
|
|
164
|
+
# Used to upload release artifacts
|
|
165
|
+
contents: write
|
|
166
|
+
# Used to generate artifact attestation
|
|
167
|
+
attestations: write
|
|
168
|
+
steps:
|
|
169
|
+
- uses: actions/download-artifact@v4
|
|
170
|
+
- name: Generate artifact attestation
|
|
171
|
+
uses: actions/attest-build-provenance@v2
|
|
172
|
+
with:
|
|
173
|
+
subject-path: 'wheels-*/*'
|
|
174
|
+
- name: Publish to PyPI
|
|
175
|
+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
|
176
|
+
uses: PyO3/maturin-action@v1
|
|
177
|
+
env:
|
|
178
|
+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
|
|
179
|
+
with:
|
|
180
|
+
command: upload
|
|
181
|
+
args: --non-interactive --skip-existing wheels-*/*
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/target
|
|
2
|
+
|
|
3
|
+
# Byte-compiled / optimized / DLL files
|
|
4
|
+
__pycache__/
|
|
5
|
+
.pytest_cache/
|
|
6
|
+
*.py[cod]
|
|
7
|
+
|
|
8
|
+
# C extensions
|
|
9
|
+
*.so
|
|
10
|
+
|
|
11
|
+
# Distribution / packaging
|
|
12
|
+
.Python
|
|
13
|
+
.venv/
|
|
14
|
+
env/
|
|
15
|
+
bin/
|
|
16
|
+
build/
|
|
17
|
+
develop-eggs/
|
|
18
|
+
dist/
|
|
19
|
+
eggs/
|
|
20
|
+
lib/
|
|
21
|
+
lib64/
|
|
22
|
+
parts/
|
|
23
|
+
sdist/
|
|
24
|
+
var/
|
|
25
|
+
include/
|
|
26
|
+
man/
|
|
27
|
+
venv/
|
|
28
|
+
*.egg-info/
|
|
29
|
+
.installed.cfg
|
|
30
|
+
*.egg
|
|
31
|
+
|
|
32
|
+
# Installer logs
|
|
33
|
+
pip-log.txt
|
|
34
|
+
pip-delete-this-directory.txt
|
|
35
|
+
pip-selfcheck.json
|
|
36
|
+
|
|
37
|
+
# Unit test / coverage reports
|
|
38
|
+
htmlcov/
|
|
39
|
+
.tox/
|
|
40
|
+
.coverage
|
|
41
|
+
.cache
|
|
42
|
+
nosetests.xml
|
|
43
|
+
coverage.xml
|
|
44
|
+
|
|
45
|
+
# Translations
|
|
46
|
+
*.mo
|
|
47
|
+
|
|
48
|
+
# Mr Developer
|
|
49
|
+
.mr.developer.cfg
|
|
50
|
+
.project
|
|
51
|
+
.pydevproject
|
|
52
|
+
|
|
53
|
+
# Rope
|
|
54
|
+
.ropeproject
|
|
55
|
+
|
|
56
|
+
# Django stuff:
|
|
57
|
+
*.log
|
|
58
|
+
*.pot
|
|
59
|
+
|
|
60
|
+
.DS_Store
|
|
61
|
+
|
|
62
|
+
# Sphinx documentation
|
|
63
|
+
docs/_build/
|
|
64
|
+
|
|
65
|
+
# PyCharm
|
|
66
|
+
.idea/
|
|
67
|
+
|
|
68
|
+
# VSCode
|
|
69
|
+
.vscode/
|
|
70
|
+
|
|
71
|
+
# Pyenv
|
|
72
|
+
.python-version
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "autocfg"
|
|
7
|
+
version = "1.5.0"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "docker-image"
|
|
13
|
+
version = "0.2.1"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "f40ed901b8f2157bafce6e96f39217f7b1a4af32d84266d251ed7c22ce001f0b"
|
|
16
|
+
dependencies = [
|
|
17
|
+
"lazy_static",
|
|
18
|
+
"regex",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[[package]]
|
|
22
|
+
name = "dockerfile-analyzer"
|
|
23
|
+
version = "0.1.0"
|
|
24
|
+
dependencies = [
|
|
25
|
+
"docker-image",
|
|
26
|
+
"parse-dockerfile",
|
|
27
|
+
"pyo3",
|
|
28
|
+
"serde",
|
|
29
|
+
"shlex",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[[package]]
|
|
33
|
+
name = "heck"
|
|
34
|
+
version = "0.5.0"
|
|
35
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
36
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
37
|
+
|
|
38
|
+
[[package]]
|
|
39
|
+
name = "indoc"
|
|
40
|
+
version = "2.0.6"
|
|
41
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
42
|
+
checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd"
|
|
43
|
+
|
|
44
|
+
[[package]]
|
|
45
|
+
name = "lazy_static"
|
|
46
|
+
version = "1.5.0"
|
|
47
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
48
|
+
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
|
49
|
+
|
|
50
|
+
[[package]]
|
|
51
|
+
name = "libc"
|
|
52
|
+
version = "0.2.175"
|
|
53
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
54
|
+
checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543"
|
|
55
|
+
|
|
56
|
+
[[package]]
|
|
57
|
+
name = "memoffset"
|
|
58
|
+
version = "0.9.1"
|
|
59
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
60
|
+
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
|
|
61
|
+
dependencies = [
|
|
62
|
+
"autocfg",
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
[[package]]
|
|
66
|
+
name = "once_cell"
|
|
67
|
+
version = "1.21.3"
|
|
68
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
69
|
+
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
|
70
|
+
|
|
71
|
+
[[package]]
|
|
72
|
+
name = "parse-dockerfile"
|
|
73
|
+
version = "0.1.1"
|
|
74
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
75
|
+
checksum = "2d74bf8e70dc43f67c1cb3f18fdc20c3c1dc30c62af2b013e1895e1089195f16"
|
|
76
|
+
dependencies = [
|
|
77
|
+
"smallvec",
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
[[package]]
|
|
81
|
+
name = "portable-atomic"
|
|
82
|
+
version = "1.11.1"
|
|
83
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
84
|
+
checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483"
|
|
85
|
+
|
|
86
|
+
[[package]]
|
|
87
|
+
name = "proc-macro2"
|
|
88
|
+
version = "1.0.97"
|
|
89
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
90
|
+
checksum = "d61789d7719defeb74ea5fe81f2fdfdbd28a803847077cecce2ff14e1472f6f1"
|
|
91
|
+
dependencies = [
|
|
92
|
+
"unicode-ident",
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
[[package]]
|
|
96
|
+
name = "pyo3"
|
|
97
|
+
version = "0.25.1"
|
|
98
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
99
|
+
checksum = "8970a78afe0628a3e3430376fc5fd76b6b45c4d43360ffd6cdd40bdde72b682a"
|
|
100
|
+
dependencies = [
|
|
101
|
+
"indoc",
|
|
102
|
+
"libc",
|
|
103
|
+
"memoffset",
|
|
104
|
+
"once_cell",
|
|
105
|
+
"portable-atomic",
|
|
106
|
+
"pyo3-build-config",
|
|
107
|
+
"pyo3-ffi",
|
|
108
|
+
"pyo3-macros",
|
|
109
|
+
"unindent",
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
[[package]]
|
|
113
|
+
name = "pyo3-build-config"
|
|
114
|
+
version = "0.25.1"
|
|
115
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
116
|
+
checksum = "458eb0c55e7ece017adeba38f2248ff3ac615e53660d7c71a238d7d2a01c7598"
|
|
117
|
+
dependencies = [
|
|
118
|
+
"once_cell",
|
|
119
|
+
"target-lexicon",
|
|
120
|
+
]
|
|
121
|
+
|
|
122
|
+
[[package]]
|
|
123
|
+
name = "pyo3-ffi"
|
|
124
|
+
version = "0.25.1"
|
|
125
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
126
|
+
checksum = "7114fe5457c61b276ab77c5055f206295b812608083644a5c5b2640c3102565c"
|
|
127
|
+
dependencies = [
|
|
128
|
+
"libc",
|
|
129
|
+
"pyo3-build-config",
|
|
130
|
+
]
|
|
131
|
+
|
|
132
|
+
[[package]]
|
|
133
|
+
name = "pyo3-macros"
|
|
134
|
+
version = "0.25.1"
|
|
135
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
136
|
+
checksum = "a8725c0a622b374d6cb051d11a0983786448f7785336139c3c94f5aa6bef7e50"
|
|
137
|
+
dependencies = [
|
|
138
|
+
"proc-macro2",
|
|
139
|
+
"pyo3-macros-backend",
|
|
140
|
+
"quote",
|
|
141
|
+
"syn",
|
|
142
|
+
]
|
|
143
|
+
|
|
144
|
+
[[package]]
|
|
145
|
+
name = "pyo3-macros-backend"
|
|
146
|
+
version = "0.25.1"
|
|
147
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
148
|
+
checksum = "4109984c22491085343c05b0dbc54ddc405c3cf7b4374fc533f5c3313a572ccc"
|
|
149
|
+
dependencies = [
|
|
150
|
+
"heck",
|
|
151
|
+
"proc-macro2",
|
|
152
|
+
"pyo3-build-config",
|
|
153
|
+
"quote",
|
|
154
|
+
"syn",
|
|
155
|
+
]
|
|
156
|
+
|
|
157
|
+
[[package]]
|
|
158
|
+
name = "quote"
|
|
159
|
+
version = "1.0.40"
|
|
160
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
161
|
+
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
|
162
|
+
dependencies = [
|
|
163
|
+
"proc-macro2",
|
|
164
|
+
]
|
|
165
|
+
|
|
166
|
+
[[package]]
|
|
167
|
+
name = "regex"
|
|
168
|
+
version = "1.11.1"
|
|
169
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
170
|
+
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
|
|
171
|
+
dependencies = [
|
|
172
|
+
"regex-automata",
|
|
173
|
+
"regex-syntax",
|
|
174
|
+
]
|
|
175
|
+
|
|
176
|
+
[[package]]
|
|
177
|
+
name = "regex-automata"
|
|
178
|
+
version = "0.4.9"
|
|
179
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
180
|
+
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
|
|
181
|
+
dependencies = [
|
|
182
|
+
"regex-syntax",
|
|
183
|
+
]
|
|
184
|
+
|
|
185
|
+
[[package]]
|
|
186
|
+
name = "regex-syntax"
|
|
187
|
+
version = "0.8.5"
|
|
188
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
189
|
+
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
|
190
|
+
|
|
191
|
+
[[package]]
|
|
192
|
+
name = "serde"
|
|
193
|
+
version = "1.0.219"
|
|
194
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
195
|
+
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
|
|
196
|
+
dependencies = [
|
|
197
|
+
"serde_derive",
|
|
198
|
+
]
|
|
199
|
+
|
|
200
|
+
[[package]]
|
|
201
|
+
name = "serde_derive"
|
|
202
|
+
version = "1.0.219"
|
|
203
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
204
|
+
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
|
|
205
|
+
dependencies = [
|
|
206
|
+
"proc-macro2",
|
|
207
|
+
"quote",
|
|
208
|
+
"syn",
|
|
209
|
+
]
|
|
210
|
+
|
|
211
|
+
[[package]]
|
|
212
|
+
name = "shlex"
|
|
213
|
+
version = "1.3.0"
|
|
214
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
215
|
+
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
|
216
|
+
|
|
217
|
+
[[package]]
|
|
218
|
+
name = "smallvec"
|
|
219
|
+
version = "1.15.1"
|
|
220
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
221
|
+
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
|
|
222
|
+
|
|
223
|
+
[[package]]
|
|
224
|
+
name = "syn"
|
|
225
|
+
version = "2.0.105"
|
|
226
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
227
|
+
checksum = "7bc3fcb250e53458e712715cf74285c1f889686520d79294a9ef3bd7aa1fc619"
|
|
228
|
+
dependencies = [
|
|
229
|
+
"proc-macro2",
|
|
230
|
+
"quote",
|
|
231
|
+
"unicode-ident",
|
|
232
|
+
]
|
|
233
|
+
|
|
234
|
+
[[package]]
|
|
235
|
+
name = "target-lexicon"
|
|
236
|
+
version = "0.13.2"
|
|
237
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
238
|
+
checksum = "e502f78cdbb8ba4718f566c418c52bc729126ffd16baee5baa718cf25dd5a69a"
|
|
239
|
+
|
|
240
|
+
[[package]]
|
|
241
|
+
name = "unicode-ident"
|
|
242
|
+
version = "1.0.18"
|
|
243
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
244
|
+
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
|
245
|
+
|
|
246
|
+
[[package]]
|
|
247
|
+
name = "unindent"
|
|
248
|
+
version = "0.2.4"
|
|
249
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
250
|
+
checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "dockerfile-analyzer"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2024"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
|
|
7
|
+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
8
|
+
[lib]
|
|
9
|
+
name = "dockerfile_analyzer"
|
|
10
|
+
crate-type = ["cdylib"]
|
|
11
|
+
|
|
12
|
+
[dependencies]
|
|
13
|
+
pyo3 = "0.25.0"
|
|
14
|
+
docker-image = {version = "0.2.1"}
|
|
15
|
+
parse-dockerfile = { version = "0.1.1", default-features = false }
|
|
16
|
+
shlex = "1.3.0"
|
|
17
|
+
serde = { version = "1.0.219", features = ["derive"] }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 societymartingale
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dockerfile-analyzer
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Classifier: Programming Language :: Rust
|
|
5
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: >=3.8
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# flake8: noqa: PYI021
|
|
2
|
+
def analyze_dockerfile(body: str) -> Analysis:
|
|
3
|
+
"""
|
|
4
|
+
Analyzes a Dockerfile and returns detailed analysis information.
|
|
5
|
+
|
|
6
|
+
Args:
|
|
7
|
+
dockerfile_content (str): The content of the Dockerfile to analyze
|
|
8
|
+
|
|
9
|
+
Returns:
|
|
10
|
+
Analysis: A comprehensive analysis object containing information about:
|
|
11
|
+
- Number of stages and stage names
|
|
12
|
+
- Base images used
|
|
13
|
+
- Multistage analysis (if applicable)
|
|
14
|
+
- Instructions statistics
|
|
15
|
+
- Environment variables, labels, and arguments
|
|
16
|
+
- Exposed ports
|
|
17
|
+
|
|
18
|
+
Raises:
|
|
19
|
+
ValueError: If the dockerfile content is empty or invalid
|
|
20
|
+
|
|
21
|
+
Example:
|
|
22
|
+
>>> analysis = analyze_dockerfile('FROM ubuntu:20.04\nRUN echo hello')
|
|
23
|
+
>>> print(analysis.num_stages)
|
|
24
|
+
1
|
|
25
|
+
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
from typing import Dict, List, Optional, Any
|
|
29
|
+
|
|
30
|
+
class Analysis:
|
|
31
|
+
num_stages: int
|
|
32
|
+
images: List[Image]
|
|
33
|
+
stage_names: List[str]
|
|
34
|
+
copy_from_stages: List[str]
|
|
35
|
+
add_from_stages: List[str]
|
|
36
|
+
multistage_analysis: MultistageAnalysis
|
|
37
|
+
exposed_ports: List[str]
|
|
38
|
+
instructions: InstructionStats
|
|
39
|
+
args: Dict[str, Optional[str]]
|
|
40
|
+
labels: Dict[str, str]
|
|
41
|
+
env_vars: Dict[str, str]
|
|
42
|
+
|
|
43
|
+
def to_dict(self) -> Dict[str, Any]: ...
|
|
44
|
+
def __repr__(self) -> str: ...
|
|
45
|
+
|
|
46
|
+
class Image:
|
|
47
|
+
full: str
|
|
48
|
+
components: Optional[ImageComponents]
|
|
49
|
+
|
|
50
|
+
def to_dict(self) -> Dict[str, Any]: ...
|
|
51
|
+
def __repr__(self) -> str: ...
|
|
52
|
+
|
|
53
|
+
class ImageComponents:
|
|
54
|
+
registry: Optional[str]
|
|
55
|
+
name: str
|
|
56
|
+
tag: Optional[str]
|
|
57
|
+
digest: Optional[str]
|
|
58
|
+
|
|
59
|
+
def to_dict(self) -> Dict[str, Any]: ...
|
|
60
|
+
def __repr__(self) -> str: ...
|
|
61
|
+
|
|
62
|
+
class InstructionStats:
|
|
63
|
+
total_count: int
|
|
64
|
+
by_type: Dict[str, int]
|
|
65
|
+
|
|
66
|
+
def to_dict(self) -> Dict[str, Any]: ...
|
|
67
|
+
def __repr__(self) -> str: ...
|
|
68
|
+
|
|
69
|
+
class MultistageAnalysis:
|
|
70
|
+
is_multistage: bool
|
|
71
|
+
stages_used_as_base_images: List[str]
|
|
72
|
+
stages_copied_from: List[str]
|
|
73
|
+
stages_added_from: List[str]
|
|
74
|
+
unused_stages: List[str]
|
|
75
|
+
|
|
76
|
+
def to_dict(self) -> Dict[str, Any]: ...
|
|
77
|
+
def __repr__(self) -> str: ...
|
|
78
|
+
|
|
79
|
+
class KeyValueInstr:
|
|
80
|
+
args: Dict[str, Optional[str]]
|
|
81
|
+
labels: Dict[str, str]
|
|
82
|
+
env_vars: Dict[str, str]
|
|
83
|
+
|
|
84
|
+
def to_dict(self) -> Dict[str, Any]: ...
|
|
85
|
+
def __repr__(self) -> str: ...
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Usage: python example.py <dockerfile path>"""
|
|
2
|
+
|
|
3
|
+
from sys import argv
|
|
4
|
+
import dockerfile_analyzer as da
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def get_dockerfile_contents(fname: str) -> str:
|
|
8
|
+
with open(fname) as f:
|
|
9
|
+
return f.read()
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def main() -> None:
|
|
13
|
+
df = get_dockerfile_contents(argv[1])
|
|
14
|
+
res = da.analyze_dockerfile(df)
|
|
15
|
+
print(res)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
if __name__ == "__main__":
|
|
19
|
+
main()
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["maturin>=1.9,<2.0"]
|
|
3
|
+
build-backend = "maturin"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "dockerfile-analyzer"
|
|
7
|
+
requires-python = ">=3.8"
|
|
8
|
+
classifiers = [
|
|
9
|
+
"Programming Language :: Rust",
|
|
10
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
11
|
+
"Programming Language :: Python :: Implementation :: PyPy",
|
|
12
|
+
]
|
|
13
|
+
dynamic = ["version"]
|
|
14
|
+
[tool.maturin]
|
|
15
|
+
features = ["pyo3/extension-module"]
|