pyrustaudit 0.0.1__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.
File without changes
@@ -0,0 +1,3 @@
1
+ include README.md
2
+ include *.go go.mod go.sum
3
+ include LICENSE
@@ -0,0 +1,301 @@
1
+ Metadata-Version: 2.1
2
+ Name: pyrustaudit
3
+ Version: 0.0.1
4
+ Summary: A utility to extract rust audit information from rust executable if audit enabled
5
+ Home-page: https://github.com/Mikemoore63/pyrustaudit
6
+ Author: Mike Moore
7
+ Author-email: z_z_zebra@yahoo.com
8
+ License: MIT
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+
15
+ A python package that extracts rust audit information from rust audit based executables.
16
+
17
+
18
+ Example usage
19
+
20
+ ```python
21
+
22
+ from pyrustaudit import get_rust_audit
23
+ import json
24
+
25
+
26
+ def test_get_info(file):
27
+ res = get_rust_audit(file)
28
+ print(json.dumps(res, indent=4))
29
+
30
+
31
+ test_get_info("foo/bar")
32
+ test_get_info("/usr/bin/du")
33
+ test_get_info("test-data/centos5-plain-Packages")
34
+
35
+ ```
36
+
37
+ The result returned is always a dict object for errors the dictionary returned contains a key;
38
+ "error" like;
39
+ ```python
40
+ {
41
+ "error": "path error:foo/bar"
42
+ }
43
+ ```
44
+ or
45
+ ```python
46
+ {
47
+ "error": "/usr/bin/du: could not read Go build info from /usr/bin/du: unrecognized file format"
48
+ }
49
+ ```
50
+ on success a python dict is rturned like this
51
+
52
+ ```python
53
+ {
54
+ "packages": [
55
+ {
56
+ "name": "adler",
57
+ "version": "1.0.2",
58
+ "source": "registry",
59
+ "kind": "build",
60
+ "dependencies": null,
61
+ "features": null,
62
+ "root": false
63
+ },
64
+ {
65
+ "name": "auditable",
66
+ "version": "0.1.0",
67
+ "source": "registry",
68
+ "kind": "runtime",
69
+ "dependencies": null,
70
+ "features": null,
71
+ "root": false
72
+ },
73
+ {
74
+ "name": "auditable-build",
75
+ "version": "0.1.0",
76
+ "source": "registry",
77
+ "kind": "build",
78
+ "dependencies": [
79
+ 3,
80
+ 5,
81
+ 7,
82
+ 15
83
+ ],
84
+ "features": null,
85
+ "root": false
86
+ },
87
+ {
88
+ "name": "auditable-serde",
89
+ "version": "0.1.0",
90
+ "source": "registry",
91
+ "kind": "build",
92
+ "dependencies": [
93
+ 5,
94
+ 11,
95
+ 13,
96
+ 15
97
+ ],
98
+ "features": [
99
+ "cargo_metadata",
100
+ "default",
101
+ "from_metadata"
102
+ ],
103
+ "root": false
104
+ },
105
+ {
106
+ "name": "autocfg",
107
+ "version": "1.2.0",
108
+ "source": "registry",
109
+ "kind": "build",
110
+ "dependencies": null,
111
+ "features": null,
112
+ "root": false
113
+ },
114
+ {
115
+ "name": "cargo_metadata",
116
+ "version": "0.11.4",
117
+ "source": "registry",
118
+ "kind": "build",
119
+ "dependencies": [
120
+ 11,
121
+ 13,
122
+ 15
123
+ ],
124
+ "features": [
125
+ "default"
126
+ ],
127
+ "root": false
128
+ },
129
+ {
130
+ "name": "itoa",
131
+ "version": "1.0.11",
132
+ "source": "registry",
133
+ "kind": "build",
134
+ "dependencies": null,
135
+ "features": null,
136
+ "root": false
137
+ },
138
+ {
139
+ "name": "miniz_oxide",
140
+ "version": "0.4.4",
141
+ "source": "registry",
142
+ "kind": "build",
143
+ "dependencies": [
144
+ 0,
145
+ 4
146
+ ],
147
+ "features": null,
148
+ "root": false
149
+ },
150
+ {
151
+ "name": "proc-macro2",
152
+ "version": "1.0.79",
153
+ "source": "registry",
154
+ "kind": "build",
155
+ "dependencies": [
156
+ 18
157
+ ],
158
+ "features": [
159
+ "proc-macro"
160
+ ],
161
+ "root": false
162
+ },
163
+ {
164
+ "name": "quote",
165
+ "version": "1.0.35",
166
+ "source": "registry",
167
+ "kind": "build",
168
+ "dependencies": [
169
+ 8
170
+ ],
171
+ "features": [
172
+ "proc-macro"
173
+ ],
174
+ "root": false
175
+ },
176
+ {
177
+ "name": "ryu",
178
+ "version": "1.0.17",
179
+ "source": "registry",
180
+ "kind": "build",
181
+ "dependencies": null,
182
+ "features": null,
183
+ "root": false
184
+ },
185
+ {
186
+ "name": "semver",
187
+ "version": "0.10.0",
188
+ "source": "registry",
189
+ "kind": "build",
190
+ "dependencies": [
191
+ 12,
192
+ 13
193
+ ],
194
+ "features": [
195
+ "default",
196
+ "serde"
197
+ ],
198
+ "root": false
199
+ },
200
+ {
201
+ "name": "semver-parser",
202
+ "version": "0.7.0",
203
+ "source": "registry",
204
+ "kind": "build",
205
+ "dependencies": null,
206
+ "features": null,
207
+ "root": false
208
+ },
209
+ {
210
+ "name": "serde",
211
+ "version": "1.0.197",
212
+ "source": "registry",
213
+ "kind": "build",
214
+ "dependencies": [
215
+ 14
216
+ ],
217
+ "features": [
218
+ "default",
219
+ "derive",
220
+ "serde_derive",
221
+ "std"
222
+ ],
223
+ "root": false
224
+ },
225
+ {
226
+ "name": "serde_derive",
227
+ "version": "1.0.197",
228
+ "source": "registry",
229
+ "kind": "build",
230
+ "dependencies": [
231
+ 8,
232
+ 9,
233
+ 16
234
+ ],
235
+ "features": [
236
+ "default"
237
+ ],
238
+ "root": false
239
+ },
240
+ {
241
+ "name": "serde_json",
242
+ "version": "1.0.115",
243
+ "source": "registry",
244
+ "kind": "build",
245
+ "dependencies": [
246
+ 6,
247
+ 10,
248
+ 13
249
+ ],
250
+ "features": [
251
+ "default",
252
+ "std"
253
+ ],
254
+ "root": false
255
+ },
256
+ {
257
+ "name": "syn",
258
+ "version": "2.0.58",
259
+ "source": "registry",
260
+ "kind": "build",
261
+ "dependencies": [
262
+ 8,
263
+ 9,
264
+ 18
265
+ ],
266
+ "features": [
267
+ "clone-impls",
268
+ "derive",
269
+ "parsing",
270
+ "printing",
271
+ "proc-macro"
272
+ ],
273
+ "root": false
274
+ },
275
+ {
276
+ "name": "test-data",
277
+ "version": "0.1.0",
278
+ "source": "local",
279
+ "kind": "runtime",
280
+ "dependencies": [
281
+ 1,
282
+ 2
283
+ ],
284
+ "features": null,
285
+ "root": false
286
+ },
287
+ {
288
+ "name": "unicode-ident",
289
+ "version": "1.0.12",
290
+ "source": "registry",
291
+ "kind": "build",
292
+ "dependencies": null,
293
+ "features": null,
294
+ "root": false
295
+ }
296
+ ]
297
+ }
298
+
299
+ ```
300
+
301
+
@@ -0,0 +1,287 @@
1
+ A python package that extracts rust audit information from rust audit based executables.
2
+
3
+
4
+ Example usage
5
+
6
+ ```python
7
+
8
+ from pyrustaudit import get_rust_audit
9
+ import json
10
+
11
+
12
+ def test_get_info(file):
13
+ res = get_rust_audit(file)
14
+ print(json.dumps(res, indent=4))
15
+
16
+
17
+ test_get_info("foo/bar")
18
+ test_get_info("/usr/bin/du")
19
+ test_get_info("test-data/centos5-plain-Packages")
20
+
21
+ ```
22
+
23
+ The result returned is always a dict object for errors the dictionary returned contains a key;
24
+ "error" like;
25
+ ```python
26
+ {
27
+ "error": "path error:foo/bar"
28
+ }
29
+ ```
30
+ or
31
+ ```python
32
+ {
33
+ "error": "/usr/bin/du: could not read Go build info from /usr/bin/du: unrecognized file format"
34
+ }
35
+ ```
36
+ on success a python dict is rturned like this
37
+
38
+ ```python
39
+ {
40
+ "packages": [
41
+ {
42
+ "name": "adler",
43
+ "version": "1.0.2",
44
+ "source": "registry",
45
+ "kind": "build",
46
+ "dependencies": null,
47
+ "features": null,
48
+ "root": false
49
+ },
50
+ {
51
+ "name": "auditable",
52
+ "version": "0.1.0",
53
+ "source": "registry",
54
+ "kind": "runtime",
55
+ "dependencies": null,
56
+ "features": null,
57
+ "root": false
58
+ },
59
+ {
60
+ "name": "auditable-build",
61
+ "version": "0.1.0",
62
+ "source": "registry",
63
+ "kind": "build",
64
+ "dependencies": [
65
+ 3,
66
+ 5,
67
+ 7,
68
+ 15
69
+ ],
70
+ "features": null,
71
+ "root": false
72
+ },
73
+ {
74
+ "name": "auditable-serde",
75
+ "version": "0.1.0",
76
+ "source": "registry",
77
+ "kind": "build",
78
+ "dependencies": [
79
+ 5,
80
+ 11,
81
+ 13,
82
+ 15
83
+ ],
84
+ "features": [
85
+ "cargo_metadata",
86
+ "default",
87
+ "from_metadata"
88
+ ],
89
+ "root": false
90
+ },
91
+ {
92
+ "name": "autocfg",
93
+ "version": "1.2.0",
94
+ "source": "registry",
95
+ "kind": "build",
96
+ "dependencies": null,
97
+ "features": null,
98
+ "root": false
99
+ },
100
+ {
101
+ "name": "cargo_metadata",
102
+ "version": "0.11.4",
103
+ "source": "registry",
104
+ "kind": "build",
105
+ "dependencies": [
106
+ 11,
107
+ 13,
108
+ 15
109
+ ],
110
+ "features": [
111
+ "default"
112
+ ],
113
+ "root": false
114
+ },
115
+ {
116
+ "name": "itoa",
117
+ "version": "1.0.11",
118
+ "source": "registry",
119
+ "kind": "build",
120
+ "dependencies": null,
121
+ "features": null,
122
+ "root": false
123
+ },
124
+ {
125
+ "name": "miniz_oxide",
126
+ "version": "0.4.4",
127
+ "source": "registry",
128
+ "kind": "build",
129
+ "dependencies": [
130
+ 0,
131
+ 4
132
+ ],
133
+ "features": null,
134
+ "root": false
135
+ },
136
+ {
137
+ "name": "proc-macro2",
138
+ "version": "1.0.79",
139
+ "source": "registry",
140
+ "kind": "build",
141
+ "dependencies": [
142
+ 18
143
+ ],
144
+ "features": [
145
+ "proc-macro"
146
+ ],
147
+ "root": false
148
+ },
149
+ {
150
+ "name": "quote",
151
+ "version": "1.0.35",
152
+ "source": "registry",
153
+ "kind": "build",
154
+ "dependencies": [
155
+ 8
156
+ ],
157
+ "features": [
158
+ "proc-macro"
159
+ ],
160
+ "root": false
161
+ },
162
+ {
163
+ "name": "ryu",
164
+ "version": "1.0.17",
165
+ "source": "registry",
166
+ "kind": "build",
167
+ "dependencies": null,
168
+ "features": null,
169
+ "root": false
170
+ },
171
+ {
172
+ "name": "semver",
173
+ "version": "0.10.0",
174
+ "source": "registry",
175
+ "kind": "build",
176
+ "dependencies": [
177
+ 12,
178
+ 13
179
+ ],
180
+ "features": [
181
+ "default",
182
+ "serde"
183
+ ],
184
+ "root": false
185
+ },
186
+ {
187
+ "name": "semver-parser",
188
+ "version": "0.7.0",
189
+ "source": "registry",
190
+ "kind": "build",
191
+ "dependencies": null,
192
+ "features": null,
193
+ "root": false
194
+ },
195
+ {
196
+ "name": "serde",
197
+ "version": "1.0.197",
198
+ "source": "registry",
199
+ "kind": "build",
200
+ "dependencies": [
201
+ 14
202
+ ],
203
+ "features": [
204
+ "default",
205
+ "derive",
206
+ "serde_derive",
207
+ "std"
208
+ ],
209
+ "root": false
210
+ },
211
+ {
212
+ "name": "serde_derive",
213
+ "version": "1.0.197",
214
+ "source": "registry",
215
+ "kind": "build",
216
+ "dependencies": [
217
+ 8,
218
+ 9,
219
+ 16
220
+ ],
221
+ "features": [
222
+ "default"
223
+ ],
224
+ "root": false
225
+ },
226
+ {
227
+ "name": "serde_json",
228
+ "version": "1.0.115",
229
+ "source": "registry",
230
+ "kind": "build",
231
+ "dependencies": [
232
+ 6,
233
+ 10,
234
+ 13
235
+ ],
236
+ "features": [
237
+ "default",
238
+ "std"
239
+ ],
240
+ "root": false
241
+ },
242
+ {
243
+ "name": "syn",
244
+ "version": "2.0.58",
245
+ "source": "registry",
246
+ "kind": "build",
247
+ "dependencies": [
248
+ 8,
249
+ 9,
250
+ 18
251
+ ],
252
+ "features": [
253
+ "clone-impls",
254
+ "derive",
255
+ "parsing",
256
+ "printing",
257
+ "proc-macro"
258
+ ],
259
+ "root": false
260
+ },
261
+ {
262
+ "name": "test-data",
263
+ "version": "0.1.0",
264
+ "source": "local",
265
+ "kind": "runtime",
266
+ "dependencies": [
267
+ 1,
268
+ 2
269
+ ],
270
+ "features": null,
271
+ "root": false
272
+ },
273
+ {
274
+ "name": "unicode-ident",
275
+ "version": "1.0.12",
276
+ "source": "registry",
277
+ "kind": "build",
278
+ "dependencies": null,
279
+ "features": null,
280
+ "root": false
281
+ }
282
+ ]
283
+ }
284
+
285
+ ```
286
+
287
+
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ from pyrustaudit import get_rust_audit
4
+ import glob
5
+ import sys
6
+ import json
7
+
8
+ for arg in sys.argv[1:]:
9
+ for file in glob.glob(arg):
10
+ result = get_rust_audit(file)
11
+ print(json.dumps(result,indent=4))
@@ -0,0 +1,5 @@
1
+ module pyrustaudit
2
+
3
+ go 1.21
4
+
5
+ require github.com/microsoft/go-rustaudit v0.0.0-20220808201409-204dfee52032
@@ -0,0 +1,10 @@
1
+ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2
+ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3
+ github.com/microsoft/go-rustaudit v0.0.0-20220808201409-204dfee52032 h1:TLygBUBxikNJJfLwgm+Qwdgq1FtfV8Uh7bcxRyTzK8s=
4
+ github.com/microsoft/go-rustaudit v0.0.0-20220808201409-204dfee52032/go.mod h1:vYT9HE7WCvL64iVeZylKmCsWKfE+JZ8105iuh2Trk8g=
5
+ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
6
+ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
7
+ github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
8
+ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
9
+ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
10
+ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
@@ -0,0 +1,31 @@
1
+ [tool.cibuildwheel]
2
+
3
+
4
+ [tool.cibuildwheel.windows]
5
+ archs=["AMD64"]
6
+ before-all = "powershell {project}\\installGo.ps1"
7
+ skip = "cp36-win*"
8
+ environment= """
9
+ PATH="C:\\Go\\bin;C:\\Program Files\\Go\\bin;$PATH"
10
+ GOPATH="C:\\Go"
11
+ """
12
+
13
+ [tool.cibuildwheel.linux]
14
+ archs=["x86_64"]
15
+ before-all = "yum install -y golang"
16
+ environment = """
17
+ CC=gcc
18
+ CGO_ENABLED=1
19
+ """
20
+
21
+ [[tool.cibuildwheel.overrides]]
22
+ select = "*-musllinux*"
23
+ before-all = "wget https://golang.org/dl/go1.21.1.linux-amd64.tar.gz;tar -C /usr/local -xzf go1.21.1.linux-amd64.tar.gz"
24
+ environment = """
25
+ PATH=$PATH:/usr/local/go/bin
26
+ CGO_ENABLED=1
27
+ CC=gcc
28
+ """
29
+
30
+
31
+
@@ -0,0 +1,36 @@
1
+ [metadata]
2
+ name = pyrustaudit
3
+ version = 0.0.1
4
+ author = Mike Moore
5
+ author_email = z_z_zebra@yahoo.com
6
+ license = MIT
7
+ description = A utility to extract rust audit information from rust executable if audit enabled
8
+ url = https://github.com/Mikemoore63/pyrustaudit
9
+ long_description = file: README.md
10
+ long_description_content_type = text/markdown
11
+ classifiers =
12
+ Programming Language :: Python :: 3
13
+ License :: OSI Approved :: MIT License
14
+ Operating System :: OS Independent
15
+
16
+ [options]
17
+ py_modules = pyrustaudit
18
+ zip_safe = False
19
+ setup_requires = setuptools-golang
20
+ scripts = get_rust_audit
21
+ package_dir =
22
+ =src
23
+ packages = find:
24
+
25
+ [options.packages.find]
26
+ where = src
27
+
28
+ [options.entry_points]
29
+ pyinstaller40 =
30
+ hook-dirs = pyrustaudit._pyinstaller:get_hook_dirs
31
+ tests = pyrustaudit._pyinstaller:get_PyInstaller_tests
32
+
33
+ [egg_info]
34
+ tag_build =
35
+ tag_date = 0
36
+
@@ -0,0 +1,9 @@
1
+
2
+ from setuptools import Extension, setup
3
+ import os
4
+
5
+ if __name__ == '__main__':
6
+ setup(
7
+ build_golang={'root': 'github.com/MikeMoore63/pyrustaudit'},
8
+ ext_modules=[Extension('pyrustaudit._pyrustaudit', ['src/pyrustaudit/pyrustaudit.go'])]
9
+ )
@@ -0,0 +1,47 @@
1
+ from __future__ import absolute_import
2
+
3
+ from pyrustaudit._pyinstaller import get_hook_dirs, get_PyInstaller_tests
4
+ __all__ = [
5
+ "get_hook_dirs",
6
+ "get_PyInstaller_tests",
7
+ "get_rust_audit"
8
+ ]
9
+
10
+ """Extract buildinfo from go built binaries"""
11
+
12
+ import ctypes
13
+ import json
14
+ import os
15
+ from distutils.sysconfig import get_config_var
16
+ from pathlib import Path
17
+
18
+
19
+ # Location of shared library
20
+ here = Path(__file__).absolute().parent
21
+ ext_suffix = get_config_var('EXT_SUFFIX')
22
+ so_file = os.path.join(here, ('_pyrustaudit' + ext_suffix))
23
+
24
+ # Load functions from shared library set their signatures
25
+ so = ctypes.cdll.LoadLibrary(so_file)
26
+ get_rust_audit_so = so.getrustAudit
27
+ get_rust_audit_so.argtypes = [ctypes.c_char_p]
28
+ get_rust_audit_so.restype = ctypes.c_void_p
29
+ free = so.free
30
+ free.argtypes = [ctypes.c_void_p]
31
+
32
+
33
+ def get_rust_audit(file_name):
34
+ """Check (in parallel) digital signature of all files in root_dir.
35
+ We assume there's a sha1sum.txt file under root_dir
36
+ """
37
+ res = get_rust_audit_so(file_name.encode('utf-8'))
38
+ if res is not None:
39
+ result = {"error": "Error converting result to json"}
40
+ try:
41
+ result = json.loads(ctypes.string_at(res).decode('utf-8'))
42
+ except json.JSONDecodeError as e:
43
+ pass
44
+ finally:
45
+ free(res)
46
+ return (result)
47
+
@@ -0,0 +1,34 @@
1
+ # This package provides a hook for PyInstaller
2
+ # needed to successfully freeze
3
+ # the :doc:`pyi_hooksample package <../__init__.py>`.
4
+ # It also provides test-data for that hook.
5
+ import os
6
+
7
+ # Functions
8
+ # =========
9
+ #
10
+ # .. _get_hook_dirs:
11
+ #
12
+ # get_hook_dirs
13
+ # -------------
14
+ #
15
+ # Tell PyInstaller where to find hooks provided by this distribution;
16
+ # this is referenced by the :ref:`hook registration <hook_registration>`.
17
+ # This function returns a list containing only the path to this
18
+ # directory, which is the location of these hooks.
19
+
20
+ def get_hook_dirs():
21
+ return [os.path.dirname(__file__)]
22
+
23
+ # .. _get_PyInstaller_tests:
24
+ #
25
+ # get_PyInstaller_tests
26
+ # ---------------------
27
+ #
28
+ # Tell PyInstaller where to find test-data of the hooks provided by this
29
+ # distribution; this is referenced by the :ref:`test-data registration
30
+ # <tests_registration>`. This function returns a list containing only
31
+ # the path to this directory, which is the location of these test-data.
32
+
33
+ def get_PyInstaller_tests():
34
+ return [os.path.dirname(__file__)]
@@ -0,0 +1,11 @@
1
+ from PyInstaller.utils.hooks import collect_dynamic_libs
2
+ from distutils.sysconfig import get_config_var
3
+ from pathlib import Path
4
+ import os
5
+
6
+ here = Path(__file__).absolute().parent.parent
7
+ print(here)
8
+ ext_suffix = get_config_var('EXT_SUFFIX')
9
+ so_file = os.path.join(here, ('_pyrustaudit' + ext_suffix))
10
+
11
+ binaries = [(so_file,'.')]
@@ -0,0 +1,45 @@
1
+ package main
2
+
3
+ import (
4
+ "C"
5
+ "encoding/json"
6
+ "errors"
7
+ "fmt"
8
+ rustaudit "github.com/microsoft/go-rustaudit"
9
+ "os"
10
+ "path/filepath"
11
+ )
12
+
13
+ //export getrustAudit
14
+ func getrustAudit(fileNameIn *C.char) *C.char {
15
+ return C.CString(getrustAuditInternal(C.GoString(fileNameIn)))
16
+ }
17
+
18
+ func main() {
19
+ //getrpmdbInfo(C.CString("/home/mike/pyrustaudit/test-data/centos5-plain-Packages"))
20
+ //getrpmdbInfo(C.CString("/home/mike/pyrustaudit/test-data/cbl-mariner-2.0-rpmdb.sqlite"))
21
+ }
22
+
23
+ func getrustAuditInternal(fileName string) string {
24
+ returnValue := "{ \"error\" : \"Unknown\" }"
25
+
26
+ r, err := os.Open(fileName)
27
+ if err != nil {
28
+ if pathErr := (*os.PathError)(nil); errors.As(err, &pathErr) && filepath.Clean(pathErr.Path) == filepath.Clean(fileName) {
29
+ returnValue = fmt.Sprintf("{ \"error\": \"path error:%v\" }", fileName)
30
+ } else {
31
+ returnValue = fmt.Sprintf("{ \"error\": \"%s: %v\"}", fileName, err)
32
+ }
33
+ } else {
34
+ pkgList, err := rustaudit.GetDependencyInfo(r)
35
+ r.Close()
36
+ if err != nil {
37
+ returnValue = fmt.Sprintf("{ \"error\": \"%s: %v\"}", fileName, err)
38
+ } else {
39
+ data, _ := json.Marshal(pkgList)
40
+ returnValue = string(data)
41
+ }
42
+ }
43
+ // fmt.Printf("%s\n", returnValue)
44
+ return returnValue
45
+ }
@@ -0,0 +1,301 @@
1
+ Metadata-Version: 2.1
2
+ Name: pyrustaudit
3
+ Version: 0.0.1
4
+ Summary: A utility to extract rust audit information from rust executable if audit enabled
5
+ Home-page: https://github.com/Mikemoore63/pyrustaudit
6
+ Author: Mike Moore
7
+ Author-email: z_z_zebra@yahoo.com
8
+ License: MIT
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+
15
+ A python package that extracts rust audit information from rust audit based executables.
16
+
17
+
18
+ Example usage
19
+
20
+ ```python
21
+
22
+ from pyrustaudit import get_rust_audit
23
+ import json
24
+
25
+
26
+ def test_get_info(file):
27
+ res = get_rust_audit(file)
28
+ print(json.dumps(res, indent=4))
29
+
30
+
31
+ test_get_info("foo/bar")
32
+ test_get_info("/usr/bin/du")
33
+ test_get_info("test-data/centos5-plain-Packages")
34
+
35
+ ```
36
+
37
+ The result returned is always a dict object for errors the dictionary returned contains a key;
38
+ "error" like;
39
+ ```python
40
+ {
41
+ "error": "path error:foo/bar"
42
+ }
43
+ ```
44
+ or
45
+ ```python
46
+ {
47
+ "error": "/usr/bin/du: could not read Go build info from /usr/bin/du: unrecognized file format"
48
+ }
49
+ ```
50
+ on success a python dict is rturned like this
51
+
52
+ ```python
53
+ {
54
+ "packages": [
55
+ {
56
+ "name": "adler",
57
+ "version": "1.0.2",
58
+ "source": "registry",
59
+ "kind": "build",
60
+ "dependencies": null,
61
+ "features": null,
62
+ "root": false
63
+ },
64
+ {
65
+ "name": "auditable",
66
+ "version": "0.1.0",
67
+ "source": "registry",
68
+ "kind": "runtime",
69
+ "dependencies": null,
70
+ "features": null,
71
+ "root": false
72
+ },
73
+ {
74
+ "name": "auditable-build",
75
+ "version": "0.1.0",
76
+ "source": "registry",
77
+ "kind": "build",
78
+ "dependencies": [
79
+ 3,
80
+ 5,
81
+ 7,
82
+ 15
83
+ ],
84
+ "features": null,
85
+ "root": false
86
+ },
87
+ {
88
+ "name": "auditable-serde",
89
+ "version": "0.1.0",
90
+ "source": "registry",
91
+ "kind": "build",
92
+ "dependencies": [
93
+ 5,
94
+ 11,
95
+ 13,
96
+ 15
97
+ ],
98
+ "features": [
99
+ "cargo_metadata",
100
+ "default",
101
+ "from_metadata"
102
+ ],
103
+ "root": false
104
+ },
105
+ {
106
+ "name": "autocfg",
107
+ "version": "1.2.0",
108
+ "source": "registry",
109
+ "kind": "build",
110
+ "dependencies": null,
111
+ "features": null,
112
+ "root": false
113
+ },
114
+ {
115
+ "name": "cargo_metadata",
116
+ "version": "0.11.4",
117
+ "source": "registry",
118
+ "kind": "build",
119
+ "dependencies": [
120
+ 11,
121
+ 13,
122
+ 15
123
+ ],
124
+ "features": [
125
+ "default"
126
+ ],
127
+ "root": false
128
+ },
129
+ {
130
+ "name": "itoa",
131
+ "version": "1.0.11",
132
+ "source": "registry",
133
+ "kind": "build",
134
+ "dependencies": null,
135
+ "features": null,
136
+ "root": false
137
+ },
138
+ {
139
+ "name": "miniz_oxide",
140
+ "version": "0.4.4",
141
+ "source": "registry",
142
+ "kind": "build",
143
+ "dependencies": [
144
+ 0,
145
+ 4
146
+ ],
147
+ "features": null,
148
+ "root": false
149
+ },
150
+ {
151
+ "name": "proc-macro2",
152
+ "version": "1.0.79",
153
+ "source": "registry",
154
+ "kind": "build",
155
+ "dependencies": [
156
+ 18
157
+ ],
158
+ "features": [
159
+ "proc-macro"
160
+ ],
161
+ "root": false
162
+ },
163
+ {
164
+ "name": "quote",
165
+ "version": "1.0.35",
166
+ "source": "registry",
167
+ "kind": "build",
168
+ "dependencies": [
169
+ 8
170
+ ],
171
+ "features": [
172
+ "proc-macro"
173
+ ],
174
+ "root": false
175
+ },
176
+ {
177
+ "name": "ryu",
178
+ "version": "1.0.17",
179
+ "source": "registry",
180
+ "kind": "build",
181
+ "dependencies": null,
182
+ "features": null,
183
+ "root": false
184
+ },
185
+ {
186
+ "name": "semver",
187
+ "version": "0.10.0",
188
+ "source": "registry",
189
+ "kind": "build",
190
+ "dependencies": [
191
+ 12,
192
+ 13
193
+ ],
194
+ "features": [
195
+ "default",
196
+ "serde"
197
+ ],
198
+ "root": false
199
+ },
200
+ {
201
+ "name": "semver-parser",
202
+ "version": "0.7.0",
203
+ "source": "registry",
204
+ "kind": "build",
205
+ "dependencies": null,
206
+ "features": null,
207
+ "root": false
208
+ },
209
+ {
210
+ "name": "serde",
211
+ "version": "1.0.197",
212
+ "source": "registry",
213
+ "kind": "build",
214
+ "dependencies": [
215
+ 14
216
+ ],
217
+ "features": [
218
+ "default",
219
+ "derive",
220
+ "serde_derive",
221
+ "std"
222
+ ],
223
+ "root": false
224
+ },
225
+ {
226
+ "name": "serde_derive",
227
+ "version": "1.0.197",
228
+ "source": "registry",
229
+ "kind": "build",
230
+ "dependencies": [
231
+ 8,
232
+ 9,
233
+ 16
234
+ ],
235
+ "features": [
236
+ "default"
237
+ ],
238
+ "root": false
239
+ },
240
+ {
241
+ "name": "serde_json",
242
+ "version": "1.0.115",
243
+ "source": "registry",
244
+ "kind": "build",
245
+ "dependencies": [
246
+ 6,
247
+ 10,
248
+ 13
249
+ ],
250
+ "features": [
251
+ "default",
252
+ "std"
253
+ ],
254
+ "root": false
255
+ },
256
+ {
257
+ "name": "syn",
258
+ "version": "2.0.58",
259
+ "source": "registry",
260
+ "kind": "build",
261
+ "dependencies": [
262
+ 8,
263
+ 9,
264
+ 18
265
+ ],
266
+ "features": [
267
+ "clone-impls",
268
+ "derive",
269
+ "parsing",
270
+ "printing",
271
+ "proc-macro"
272
+ ],
273
+ "root": false
274
+ },
275
+ {
276
+ "name": "test-data",
277
+ "version": "0.1.0",
278
+ "source": "local",
279
+ "kind": "runtime",
280
+ "dependencies": [
281
+ 1,
282
+ 2
283
+ ],
284
+ "features": null,
285
+ "root": false
286
+ },
287
+ {
288
+ "name": "unicode-ident",
289
+ "version": "1.0.12",
290
+ "source": "registry",
291
+ "kind": "build",
292
+ "dependencies": null,
293
+ "features": null,
294
+ "root": false
295
+ }
296
+ ]
297
+ }
298
+
299
+ ```
300
+
301
+
@@ -0,0 +1,19 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ get_rust_audit
5
+ go.mod
6
+ go.sum
7
+ pyproject.toml
8
+ setup.cfg
9
+ setup.py
10
+ src/pyrustaudit/__init__.py
11
+ src/pyrustaudit/pyrustaudit.go
12
+ src/pyrustaudit.egg-info/PKG-INFO
13
+ src/pyrustaudit.egg-info/SOURCES.txt
14
+ src/pyrustaudit.egg-info/dependency_links.txt
15
+ src/pyrustaudit.egg-info/entry_points.txt
16
+ src/pyrustaudit.egg-info/not-zip-safe
17
+ src/pyrustaudit.egg-info/top_level.txt
18
+ src/pyrustaudit/_pyinstaller/__init__.py
19
+ src/pyrustaudit/_pyinstaller/hook-pyrpmdb.py
@@ -0,0 +1,3 @@
1
+ [pyinstaller40]
2
+ hook-dirs = pyrustaudit._pyinstaller:get_hook_dirs
3
+ tests = pyrustaudit._pyinstaller:get_PyInstaller_tests
@@ -0,0 +1 @@
1
+ pyrustaudit