codedd-cli 0.1.1__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.
- codedd_cli/__init__.py +3 -0
- codedd_cli/__main__.py +19 -0
- codedd_cli/api/__init__.py +4 -0
- codedd_cli/api/client.py +120 -0
- codedd_cli/api/endpoints.py +44 -0
- codedd_cli/api/exceptions.py +24 -0
- codedd_cli/auditor/__init__.py +6 -0
- codedd_cli/auditor/architecture_analyzer.py +1251 -0
- codedd_cli/auditor/architecture_prompts.py +173 -0
- codedd_cli/auditor/complexity_analyzer.py +1739 -0
- codedd_cli/auditor/dependency_scanner.py +2485 -0
- codedd_cli/auditor/file_auditor.py +578 -0
- codedd_cli/auditor/git_stats_collector.py +417 -0
- codedd_cli/auditor/response_parser.py +484 -0
- codedd_cli/auditor/vulnerability_validator.py +323 -0
- codedd_cli/auth/__init__.py +4 -0
- codedd_cli/auth/session.py +40 -0
- codedd_cli/auth/token_manager.py +86 -0
- codedd_cli/cli.py +69 -0
- codedd_cli/commands/__init__.py +1 -0
- codedd_cli/commands/audit_cmd.py +1987 -0
- codedd_cli/commands/audits_cmd.py +276 -0
- codedd_cli/commands/auth_cmd.py +235 -0
- codedd_cli/commands/config_cmd.py +421 -0
- codedd_cli/commands/scope_cmd.py +1016 -0
- codedd_cli/config/__init__.py +4 -0
- codedd_cli/config/constants.py +22 -0
- codedd_cli/config/settings.py +389 -0
- codedd_cli/llm/__init__.py +1 -0
- codedd_cli/llm/key_manager.py +267 -0
- codedd_cli/models/__init__.py +5 -0
- codedd_cli/models/account.py +13 -0
- codedd_cli/models/audit.py +31 -0
- codedd_cli/models/local_directory.py +25 -0
- codedd_cli/scanner/__init__.py +18 -0
- codedd_cli/scanner/file_classifier.py +752 -0
- codedd_cli/scanner/file_walker.py +213 -0
- codedd_cli/scanner/line_counter.py +80 -0
- codedd_cli/utils/__init__.py +1 -0
- codedd_cli/utils/directory_validator.py +178 -0
- codedd_cli/utils/display.py +497 -0
- codedd_cli/utils/payload_inspector.py +178 -0
- codedd_cli/utils/security.py +14 -0
- codedd_cli/utils/validators.py +37 -0
- codedd_cli-0.1.1.dist-info/METADATA +306 -0
- codedd_cli-0.1.1.dist-info/RECORD +49 -0
- codedd_cli-0.1.1.dist-info/WHEEL +4 -0
- codedd_cli-0.1.1.dist-info/entry_points.txt +3 -0
- codedd_cli-0.1.1.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,752 @@
|
|
|
1
|
+
"""
|
|
2
|
+
File type classification for the local scanner.
|
|
3
|
+
|
|
4
|
+
Mirrors the server-side ``file_extensions.py`` logic so that the metadata
|
|
5
|
+
produced locally matches exactly what the CodeDD platform expects.
|
|
6
|
+
|
|
7
|
+
Categories:
|
|
8
|
+
Source Code, Configuration, Documentation, Data File,
|
|
9
|
+
Binary, Media, Archive, System, Security, Other
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import os
|
|
13
|
+
|
|
14
|
+
# ---------------------------------------------------------------------------
|
|
15
|
+
# Extension sets — kept in sync with the server-side definitions
|
|
16
|
+
# ---------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
CONFIGURATION_FILES = {
|
|
19
|
+
".yaml",
|
|
20
|
+
".yml",
|
|
21
|
+
".ini",
|
|
22
|
+
"__init__.py",
|
|
23
|
+
".env",
|
|
24
|
+
".conf",
|
|
25
|
+
".config",
|
|
26
|
+
".cfg",
|
|
27
|
+
".properties",
|
|
28
|
+
".prefs",
|
|
29
|
+
".props",
|
|
30
|
+
".toml",
|
|
31
|
+
".cnf",
|
|
32
|
+
".json",
|
|
33
|
+
".dist",
|
|
34
|
+
".opt",
|
|
35
|
+
".plist",
|
|
36
|
+
".reg",
|
|
37
|
+
".settings",
|
|
38
|
+
".editorconfig",
|
|
39
|
+
".htaccess",
|
|
40
|
+
".htpasswd",
|
|
41
|
+
".npmrc",
|
|
42
|
+
".nvmrc",
|
|
43
|
+
".bowerrc",
|
|
44
|
+
".eslintrc",
|
|
45
|
+
".prettierrc",
|
|
46
|
+
".stylelintrc",
|
|
47
|
+
".babelrc",
|
|
48
|
+
".eslintignore",
|
|
49
|
+
".prettierignore",
|
|
50
|
+
".dockerignore",
|
|
51
|
+
".gitignore",
|
|
52
|
+
".env.local",
|
|
53
|
+
".env.development",
|
|
54
|
+
".env.production",
|
|
55
|
+
".env.test",
|
|
56
|
+
"Dockerfile",
|
|
57
|
+
"docker-compose.yml",
|
|
58
|
+
"Makefile",
|
|
59
|
+
"CMakeLists.txt",
|
|
60
|
+
"webpack.config.js",
|
|
61
|
+
"rollup.config.js",
|
|
62
|
+
"vite.config.js",
|
|
63
|
+
"snowpack.config.js",
|
|
64
|
+
"tsconfig.json",
|
|
65
|
+
"package.json",
|
|
66
|
+
"composer.json",
|
|
67
|
+
"project.json",
|
|
68
|
+
"angular.json",
|
|
69
|
+
"nx.json",
|
|
70
|
+
"lerna.json",
|
|
71
|
+
"rush.json",
|
|
72
|
+
".travis.yml",
|
|
73
|
+
".gitlab-ci.yml",
|
|
74
|
+
".github/workflows",
|
|
75
|
+
"Jenkinsfile",
|
|
76
|
+
"azure-pipelines.yml",
|
|
77
|
+
".circleci/config.yml",
|
|
78
|
+
"bitbucket-pipelines.yml",
|
|
79
|
+
"buildkite.yml",
|
|
80
|
+
"appveyor.yml",
|
|
81
|
+
"cloudbuild.yaml",
|
|
82
|
+
"codeship-services.yml",
|
|
83
|
+
"setup.cfg",
|
|
84
|
+
"pyproject.toml",
|
|
85
|
+
"requirements.txt",
|
|
86
|
+
"Pipfile",
|
|
87
|
+
"tox.ini",
|
|
88
|
+
"pytest.ini",
|
|
89
|
+
".coveragerc",
|
|
90
|
+
".flake8",
|
|
91
|
+
"poetry.lock",
|
|
92
|
+
"conda.yaml",
|
|
93
|
+
"environment.yml",
|
|
94
|
+
"setup.py",
|
|
95
|
+
"MANIFEST.in",
|
|
96
|
+
"docker-compose.override.yml",
|
|
97
|
+
"docker-compose.prod.yml",
|
|
98
|
+
"docker-compose.dev.yml",
|
|
99
|
+
"kubernetes.yaml",
|
|
100
|
+
"helm.yaml",
|
|
101
|
+
"values.yaml",
|
|
102
|
+
"Chart.yaml",
|
|
103
|
+
"kustomization.yaml",
|
|
104
|
+
"terraform.tfvars",
|
|
105
|
+
"terragrunt.hcl",
|
|
106
|
+
"serverless.yml",
|
|
107
|
+
"cloudformation.yaml",
|
|
108
|
+
"pulumi.yaml",
|
|
109
|
+
"ansible.cfg",
|
|
110
|
+
"inventory.yml",
|
|
111
|
+
"playbook.yml",
|
|
112
|
+
".browserslistrc",
|
|
113
|
+
".postcssrc",
|
|
114
|
+
".cssnanorc",
|
|
115
|
+
".stylelintignore",
|
|
116
|
+
"tailwind.config.js",
|
|
117
|
+
"next.config.js",
|
|
118
|
+
"nuxt.config.js",
|
|
119
|
+
"svelte.config.js",
|
|
120
|
+
"remix.config.js",
|
|
121
|
+
"astro.config.mjs",
|
|
122
|
+
".parcelrc",
|
|
123
|
+
"gatsby-config.js",
|
|
124
|
+
"gunicorn.conf.py",
|
|
125
|
+
"uwsgi.ini",
|
|
126
|
+
"nginx.conf",
|
|
127
|
+
"apache2.conf",
|
|
128
|
+
"php.ini",
|
|
129
|
+
"my.cnf",
|
|
130
|
+
"postgresql.conf",
|
|
131
|
+
"redis.conf",
|
|
132
|
+
"supervisord.conf",
|
|
133
|
+
"pm2.config.js",
|
|
134
|
+
"nodemon.json",
|
|
135
|
+
"nest-cli.json",
|
|
136
|
+
"vercel.json",
|
|
137
|
+
".nycrc",
|
|
138
|
+
".mocharc",
|
|
139
|
+
".jestrc",
|
|
140
|
+
"karma.conf.js",
|
|
141
|
+
"cypress.json",
|
|
142
|
+
"playwright.config.js",
|
|
143
|
+
"sonar-project.properties",
|
|
144
|
+
".yamllint",
|
|
145
|
+
"vitest.config.js",
|
|
146
|
+
"ava.config.js",
|
|
147
|
+
"wallaby.js",
|
|
148
|
+
"jasmine.json",
|
|
149
|
+
".vscode/settings.json",
|
|
150
|
+
".vscode/launch.json",
|
|
151
|
+
".idea/workspace.xml",
|
|
152
|
+
".eclipse/org.eclipse.jdt.core.prefs",
|
|
153
|
+
".netbeans/project.properties",
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
SOURCE_CODE_FILES = {
|
|
157
|
+
".js",
|
|
158
|
+
".jsx",
|
|
159
|
+
".ts",
|
|
160
|
+
".tsx",
|
|
161
|
+
".vue",
|
|
162
|
+
".svelte",
|
|
163
|
+
".php",
|
|
164
|
+
".html",
|
|
165
|
+
".htm",
|
|
166
|
+
".css",
|
|
167
|
+
".scss",
|
|
168
|
+
".sass",
|
|
169
|
+
".less",
|
|
170
|
+
".styl",
|
|
171
|
+
".wasm",
|
|
172
|
+
".mjs",
|
|
173
|
+
".cjs",
|
|
174
|
+
".astro",
|
|
175
|
+
".mdx",
|
|
176
|
+
".razor",
|
|
177
|
+
".cshtml",
|
|
178
|
+
".jsp",
|
|
179
|
+
".asp",
|
|
180
|
+
".aspx",
|
|
181
|
+
".php4",
|
|
182
|
+
".php5",
|
|
183
|
+
".phtml",
|
|
184
|
+
".ctp",
|
|
185
|
+
".module",
|
|
186
|
+
".inc.php",
|
|
187
|
+
".d.ts",
|
|
188
|
+
".js.map",
|
|
189
|
+
".mts",
|
|
190
|
+
".cts",
|
|
191
|
+
".jsx.map",
|
|
192
|
+
".tsx.map",
|
|
193
|
+
".es6",
|
|
194
|
+
".es",
|
|
195
|
+
".iife.js",
|
|
196
|
+
".umd.js",
|
|
197
|
+
".amd.js",
|
|
198
|
+
".esm.js",
|
|
199
|
+
".py",
|
|
200
|
+
".java",
|
|
201
|
+
".cpp",
|
|
202
|
+
".cc",
|
|
203
|
+
".cxx",
|
|
204
|
+
".hpp",
|
|
205
|
+
".c",
|
|
206
|
+
".h",
|
|
207
|
+
".cs",
|
|
208
|
+
".fs",
|
|
209
|
+
".go",
|
|
210
|
+
".rs",
|
|
211
|
+
".rb",
|
|
212
|
+
".rake",
|
|
213
|
+
".swift",
|
|
214
|
+
".kt",
|
|
215
|
+
".kts",
|
|
216
|
+
".scala",
|
|
217
|
+
".sc",
|
|
218
|
+
".clj",
|
|
219
|
+
".cljs",
|
|
220
|
+
".cljc",
|
|
221
|
+
".erl",
|
|
222
|
+
".ex",
|
|
223
|
+
".exs",
|
|
224
|
+
".hs",
|
|
225
|
+
".lhs",
|
|
226
|
+
".lua",
|
|
227
|
+
".pl",
|
|
228
|
+
".pm",
|
|
229
|
+
".t",
|
|
230
|
+
".r",
|
|
231
|
+
".rmd",
|
|
232
|
+
".jl",
|
|
233
|
+
".dart",
|
|
234
|
+
".groovy",
|
|
235
|
+
".tcl",
|
|
236
|
+
".nim",
|
|
237
|
+
".cr",
|
|
238
|
+
".ml",
|
|
239
|
+
".re",
|
|
240
|
+
".res",
|
|
241
|
+
".elm",
|
|
242
|
+
".zig",
|
|
243
|
+
".v",
|
|
244
|
+
".gleam",
|
|
245
|
+
".hx",
|
|
246
|
+
".ceylon",
|
|
247
|
+
".idr",
|
|
248
|
+
".purs",
|
|
249
|
+
".dhall",
|
|
250
|
+
".bal",
|
|
251
|
+
".rkt",
|
|
252
|
+
".io",
|
|
253
|
+
".sh",
|
|
254
|
+
".bash",
|
|
255
|
+
".zsh",
|
|
256
|
+
".fish",
|
|
257
|
+
".bat",
|
|
258
|
+
".cmd",
|
|
259
|
+
".ps1",
|
|
260
|
+
".psm1",
|
|
261
|
+
".vbs",
|
|
262
|
+
".vba",
|
|
263
|
+
".awk",
|
|
264
|
+
".sed",
|
|
265
|
+
".ksh",
|
|
266
|
+
".csh",
|
|
267
|
+
".tcsh",
|
|
268
|
+
".nu",
|
|
269
|
+
".erb",
|
|
270
|
+
".haml",
|
|
271
|
+
".slim",
|
|
272
|
+
".pug",
|
|
273
|
+
".jade",
|
|
274
|
+
".jinja",
|
|
275
|
+
".jinja2",
|
|
276
|
+
".mustache",
|
|
277
|
+
".handlebars",
|
|
278
|
+
".hbs",
|
|
279
|
+
".twig",
|
|
280
|
+
".liquid",
|
|
281
|
+
".njk",
|
|
282
|
+
".blade.php",
|
|
283
|
+
".volt",
|
|
284
|
+
".latte",
|
|
285
|
+
".smarty",
|
|
286
|
+
".plates",
|
|
287
|
+
".tpl",
|
|
288
|
+
".sql",
|
|
289
|
+
".hql",
|
|
290
|
+
".cypher",
|
|
291
|
+
".graphql",
|
|
292
|
+
".gql",
|
|
293
|
+
".proto",
|
|
294
|
+
".thrift",
|
|
295
|
+
".cmake",
|
|
296
|
+
".gradle",
|
|
297
|
+
".m4",
|
|
298
|
+
".am",
|
|
299
|
+
".in",
|
|
300
|
+
".ac",
|
|
301
|
+
".f90",
|
|
302
|
+
".f95",
|
|
303
|
+
".f03",
|
|
304
|
+
".m",
|
|
305
|
+
".mm",
|
|
306
|
+
".xib",
|
|
307
|
+
".storyboard",
|
|
308
|
+
".gd",
|
|
309
|
+
".unity",
|
|
310
|
+
".unityproj",
|
|
311
|
+
".prefab",
|
|
312
|
+
".mat",
|
|
313
|
+
".shader",
|
|
314
|
+
".hlsl",
|
|
315
|
+
".cg",
|
|
316
|
+
".fx",
|
|
317
|
+
".fxh",
|
|
318
|
+
".usf",
|
|
319
|
+
".ush",
|
|
320
|
+
".ipynb",
|
|
321
|
+
".sage",
|
|
322
|
+
".sce",
|
|
323
|
+
".sci",
|
|
324
|
+
".stan",
|
|
325
|
+
".do",
|
|
326
|
+
".sps",
|
|
327
|
+
".sas",
|
|
328
|
+
".mlx",
|
|
329
|
+
".mplstyle",
|
|
330
|
+
".py3",
|
|
331
|
+
".pyx",
|
|
332
|
+
".pxd",
|
|
333
|
+
".pxi",
|
|
334
|
+
".rpy",
|
|
335
|
+
".rpym",
|
|
336
|
+
".rviz",
|
|
337
|
+
".asm",
|
|
338
|
+
".s",
|
|
339
|
+
".nasm",
|
|
340
|
+
".gas",
|
|
341
|
+
".lst",
|
|
342
|
+
".mac",
|
|
343
|
+
".vh",
|
|
344
|
+
".vhd",
|
|
345
|
+
".vhdl",
|
|
346
|
+
".sv",
|
|
347
|
+
".svh",
|
|
348
|
+
".svi",
|
|
349
|
+
".mli",
|
|
350
|
+
".fsi",
|
|
351
|
+
".fsx",
|
|
352
|
+
".fsscript",
|
|
353
|
+
".scm",
|
|
354
|
+
".ss",
|
|
355
|
+
".rktl",
|
|
356
|
+
".odin",
|
|
357
|
+
".d",
|
|
358
|
+
".di",
|
|
359
|
+
".mod.c",
|
|
360
|
+
".dts",
|
|
361
|
+
".dtsi",
|
|
362
|
+
".prisma",
|
|
363
|
+
".sdl",
|
|
364
|
+
".openapi",
|
|
365
|
+
".swagger",
|
|
366
|
+
".raml",
|
|
367
|
+
".wsdl",
|
|
368
|
+
".wsf",
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
DOCUMENTATION_FILES = {
|
|
372
|
+
".md",
|
|
373
|
+
".markdown",
|
|
374
|
+
".txt",
|
|
375
|
+
".rtf",
|
|
376
|
+
".rst",
|
|
377
|
+
".asciidoc",
|
|
378
|
+
".adoc",
|
|
379
|
+
".tex",
|
|
380
|
+
".latex",
|
|
381
|
+
".wiki",
|
|
382
|
+
".org",
|
|
383
|
+
".pod",
|
|
384
|
+
".rdoc",
|
|
385
|
+
".textile",
|
|
386
|
+
".creole",
|
|
387
|
+
".mediawiki",
|
|
388
|
+
".dokuwiki",
|
|
389
|
+
".asc",
|
|
390
|
+
".man",
|
|
391
|
+
".mdwn",
|
|
392
|
+
".doc",
|
|
393
|
+
".docx",
|
|
394
|
+
".odt",
|
|
395
|
+
".pages",
|
|
396
|
+
".wpd",
|
|
397
|
+
".wps",
|
|
398
|
+
".pdf",
|
|
399
|
+
".xps",
|
|
400
|
+
".oxps",
|
|
401
|
+
".epub",
|
|
402
|
+
".mobi",
|
|
403
|
+
".ppt",
|
|
404
|
+
".pptx",
|
|
405
|
+
".key",
|
|
406
|
+
".odp",
|
|
407
|
+
".pps",
|
|
408
|
+
".ppsx",
|
|
409
|
+
".xls",
|
|
410
|
+
".xlsx",
|
|
411
|
+
".numbers",
|
|
412
|
+
".ods",
|
|
413
|
+
".csv",
|
|
414
|
+
".tsv",
|
|
415
|
+
".drawio",
|
|
416
|
+
".vsdx",
|
|
417
|
+
".vsd",
|
|
418
|
+
".dgml",
|
|
419
|
+
".dgm",
|
|
420
|
+
"CHANGELOG",
|
|
421
|
+
"CONTRIBUTING",
|
|
422
|
+
"AUTHORS",
|
|
423
|
+
"MAINTAINERS",
|
|
424
|
+
"SECURITY",
|
|
425
|
+
"SUPPORT",
|
|
426
|
+
"THANKS",
|
|
427
|
+
"UPGRADING",
|
|
428
|
+
"VERSION",
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
DATA_FILES = {
|
|
432
|
+
".json",
|
|
433
|
+
".xml",
|
|
434
|
+
".yaml",
|
|
435
|
+
".yml",
|
|
436
|
+
".csv",
|
|
437
|
+
".tsv",
|
|
438
|
+
".xlsx",
|
|
439
|
+
".xls",
|
|
440
|
+
".parquet",
|
|
441
|
+
".orc",
|
|
442
|
+
".avro",
|
|
443
|
+
".arrow",
|
|
444
|
+
".feather",
|
|
445
|
+
".jsonl",
|
|
446
|
+
".ndjson",
|
|
447
|
+
".db",
|
|
448
|
+
".sqlite",
|
|
449
|
+
".sqlite3",
|
|
450
|
+
".mdb",
|
|
451
|
+
".accdb",
|
|
452
|
+
".dbf",
|
|
453
|
+
".fdb",
|
|
454
|
+
".rdb",
|
|
455
|
+
".pdb",
|
|
456
|
+
".odb",
|
|
457
|
+
".mdf",
|
|
458
|
+
".ldf",
|
|
459
|
+
".frm",
|
|
460
|
+
".ibd",
|
|
461
|
+
".hdf",
|
|
462
|
+
".h5",
|
|
463
|
+
".fits",
|
|
464
|
+
".nc",
|
|
465
|
+
".cdf",
|
|
466
|
+
".grib",
|
|
467
|
+
".shp",
|
|
468
|
+
".shx",
|
|
469
|
+
".kml",
|
|
470
|
+
".kmz",
|
|
471
|
+
".gpx",
|
|
472
|
+
".osm",
|
|
473
|
+
".geojson",
|
|
474
|
+
".pb",
|
|
475
|
+
".pbtxt",
|
|
476
|
+
".ckpt",
|
|
477
|
+
".tflite",
|
|
478
|
+
".onnx",
|
|
479
|
+
".pt",
|
|
480
|
+
".pth",
|
|
481
|
+
".safetensors",
|
|
482
|
+
".npy",
|
|
483
|
+
".npz",
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
BINARY_FILES = {
|
|
487
|
+
".exe",
|
|
488
|
+
".msi",
|
|
489
|
+
".app",
|
|
490
|
+
".dmg",
|
|
491
|
+
".pkg",
|
|
492
|
+
".deb",
|
|
493
|
+
".rpm",
|
|
494
|
+
".apk",
|
|
495
|
+
".ipa",
|
|
496
|
+
".dll",
|
|
497
|
+
".so",
|
|
498
|
+
".dylib",
|
|
499
|
+
".a",
|
|
500
|
+
".lib",
|
|
501
|
+
".jar",
|
|
502
|
+
".war",
|
|
503
|
+
".ear",
|
|
504
|
+
".aar",
|
|
505
|
+
".gem",
|
|
506
|
+
".whl",
|
|
507
|
+
".egg",
|
|
508
|
+
".pyd",
|
|
509
|
+
".pyo",
|
|
510
|
+
".pyc",
|
|
511
|
+
".obj",
|
|
512
|
+
".o",
|
|
513
|
+
".ko",
|
|
514
|
+
".class",
|
|
515
|
+
".dex",
|
|
516
|
+
".ilk",
|
|
517
|
+
".exp",
|
|
518
|
+
".pch",
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
MEDIA_FILES = {
|
|
522
|
+
".jpg",
|
|
523
|
+
".jpeg",
|
|
524
|
+
".png",
|
|
525
|
+
".gif",
|
|
526
|
+
".bmp",
|
|
527
|
+
".tiff",
|
|
528
|
+
".tif",
|
|
529
|
+
".webp",
|
|
530
|
+
".heic",
|
|
531
|
+
".heif",
|
|
532
|
+
".raw",
|
|
533
|
+
".psd",
|
|
534
|
+
".ico",
|
|
535
|
+
".icns",
|
|
536
|
+
".avif",
|
|
537
|
+
".svg",
|
|
538
|
+
".eps",
|
|
539
|
+
".ai",
|
|
540
|
+
".mp3",
|
|
541
|
+
".wav",
|
|
542
|
+
".flac",
|
|
543
|
+
".m4a",
|
|
544
|
+
".aac",
|
|
545
|
+
".ogg",
|
|
546
|
+
".wma",
|
|
547
|
+
".opus",
|
|
548
|
+
".mp4",
|
|
549
|
+
".mkv",
|
|
550
|
+
".avi",
|
|
551
|
+
".mov",
|
|
552
|
+
".wmv",
|
|
553
|
+
".flv",
|
|
554
|
+
".webm",
|
|
555
|
+
".m4v",
|
|
556
|
+
".fbx",
|
|
557
|
+
".3ds",
|
|
558
|
+
".blend",
|
|
559
|
+
".stl",
|
|
560
|
+
".dae",
|
|
561
|
+
".dwg",
|
|
562
|
+
".dxf",
|
|
563
|
+
".glb",
|
|
564
|
+
".gltf",
|
|
565
|
+
".usdz",
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
ARCHIVE_FILES = {
|
|
569
|
+
".zip",
|
|
570
|
+
".rar",
|
|
571
|
+
".7z",
|
|
572
|
+
".tar",
|
|
573
|
+
".gz",
|
|
574
|
+
".bz2",
|
|
575
|
+
".xz",
|
|
576
|
+
".tgz",
|
|
577
|
+
".tbz2",
|
|
578
|
+
".txz",
|
|
579
|
+
".cab",
|
|
580
|
+
".iso",
|
|
581
|
+
".bak",
|
|
582
|
+
".backup",
|
|
583
|
+
".bkp",
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
SYSTEM_FILES = {
|
|
587
|
+
".tmp",
|
|
588
|
+
".temp",
|
|
589
|
+
".swp",
|
|
590
|
+
".swo",
|
|
591
|
+
".swn",
|
|
592
|
+
".cache",
|
|
593
|
+
".part",
|
|
594
|
+
".crdownload",
|
|
595
|
+
".log",
|
|
596
|
+
".logs",
|
|
597
|
+
".out",
|
|
598
|
+
".err",
|
|
599
|
+
".dump",
|
|
600
|
+
".dmp",
|
|
601
|
+
".crash",
|
|
602
|
+
".core",
|
|
603
|
+
".lnk",
|
|
604
|
+
".url",
|
|
605
|
+
".pid",
|
|
606
|
+
".lock",
|
|
607
|
+
".sock",
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
SECURITY_FILES = {
|
|
611
|
+
".key",
|
|
612
|
+
".pem",
|
|
613
|
+
".crt",
|
|
614
|
+
".cer",
|
|
615
|
+
".der",
|
|
616
|
+
".p12",
|
|
617
|
+
".pfx",
|
|
618
|
+
".p7b",
|
|
619
|
+
".p7c",
|
|
620
|
+
".keystore",
|
|
621
|
+
".jks",
|
|
622
|
+
".truststore",
|
|
623
|
+
".csr",
|
|
624
|
+
".pub",
|
|
625
|
+
".gpg",
|
|
626
|
+
".asc",
|
|
627
|
+
".htpasswd",
|
|
628
|
+
".netrc",
|
|
629
|
+
".pgpass",
|
|
630
|
+
".secrets",
|
|
631
|
+
".credentials",
|
|
632
|
+
".kdbx",
|
|
633
|
+
".vault",
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
# Directories always excluded from scanning
|
|
637
|
+
EXCLUDED_DIRECTORIES = {
|
|
638
|
+
".git",
|
|
639
|
+
"__pycache__",
|
|
640
|
+
"node_modules",
|
|
641
|
+
".venv",
|
|
642
|
+
"venv",
|
|
643
|
+
"env",
|
|
644
|
+
".tox",
|
|
645
|
+
".mypy_cache",
|
|
646
|
+
".pytest_cache",
|
|
647
|
+
".ruff_cache",
|
|
648
|
+
".next",
|
|
649
|
+
".nuxt",
|
|
650
|
+
"dist",
|
|
651
|
+
"build",
|
|
652
|
+
".build",
|
|
653
|
+
"target",
|
|
654
|
+
"out",
|
|
655
|
+
"bin",
|
|
656
|
+
".gradle",
|
|
657
|
+
".mvn",
|
|
658
|
+
".idea",
|
|
659
|
+
".vscode",
|
|
660
|
+
".vs",
|
|
661
|
+
"vendor",
|
|
662
|
+
"bower_components",
|
|
663
|
+
".terraform",
|
|
664
|
+
".serverless",
|
|
665
|
+
"coverage",
|
|
666
|
+
".nyc_output",
|
|
667
|
+
"htmlcov",
|
|
668
|
+
".eggs",
|
|
669
|
+
"*.egg-info",
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
def get_file_extension(file_path: str) -> str:
|
|
674
|
+
"""Extract the file extension from a path (lowercase)."""
|
|
675
|
+
return os.path.splitext(file_path)[1].lower()
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
def get_file_type(file_path: str) -> str:
|
|
679
|
+
"""
|
|
680
|
+
Determine the type of file based on its extension or filename.
|
|
681
|
+
|
|
682
|
+
Returns one of: 'Source Code', 'Configuration', 'Documentation',
|
|
683
|
+
'Data File', 'Binary', 'Media', 'Archive', 'System', 'Security', 'Other'.
|
|
684
|
+
"""
|
|
685
|
+
filename = os.path.basename(file_path)
|
|
686
|
+
|
|
687
|
+
# Check complete filename first (e.g. "Dockerfile", "Makefile")
|
|
688
|
+
if filename in CONFIGURATION_FILES:
|
|
689
|
+
return "Configuration"
|
|
690
|
+
if filename in DOCUMENTATION_FILES:
|
|
691
|
+
return "Documentation"
|
|
692
|
+
|
|
693
|
+
# Try the last extension (handles compound like .d.ts)
|
|
694
|
+
parts = filename.split(".")
|
|
695
|
+
if len(parts) > 1:
|
|
696
|
+
last_ext = f".{parts[-1]}"
|
|
697
|
+
for ext_set, label in _EXTENSION_ORDER:
|
|
698
|
+
if last_ext in ext_set:
|
|
699
|
+
return label
|
|
700
|
+
|
|
701
|
+
# Fall back to os.path.splitext
|
|
702
|
+
extension = get_file_extension(file_path)
|
|
703
|
+
for ext_set, label in _EXTENSION_ORDER:
|
|
704
|
+
if extension in ext_set:
|
|
705
|
+
return label
|
|
706
|
+
|
|
707
|
+
return "Other"
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
# Lookup order (source code first to match server behaviour)
|
|
711
|
+
_EXTENSION_ORDER = [
|
|
712
|
+
(SOURCE_CODE_FILES, "Source Code"),
|
|
713
|
+
(CONFIGURATION_FILES, "Configuration"),
|
|
714
|
+
(DOCUMENTATION_FILES, "Documentation"),
|
|
715
|
+
(DATA_FILES, "Data File"),
|
|
716
|
+
(BINARY_FILES, "Binary"),
|
|
717
|
+
(MEDIA_FILES, "Media"),
|
|
718
|
+
(ARCHIVE_FILES, "Archive"),
|
|
719
|
+
(SYSTEM_FILES, "System"),
|
|
720
|
+
(SECURITY_FILES, "Security"),
|
|
721
|
+
]
|
|
722
|
+
|
|
723
|
+
|
|
724
|
+
def should_exclude_file(file_path: str) -> bool:
|
|
725
|
+
"""
|
|
726
|
+
Return True if a file should be excluded from LoC counting.
|
|
727
|
+
|
|
728
|
+
Excluded: files inside .git directories, configuration files, and
|
|
729
|
+
non-source categories (docs, data, binary, media, archives, system, security).
|
|
730
|
+
"""
|
|
731
|
+
# Anything inside a .git directory
|
|
732
|
+
parts = file_path.replace("\\", "/").split("/")
|
|
733
|
+
if ".git" in parts:
|
|
734
|
+
return True
|
|
735
|
+
|
|
736
|
+
filename = os.path.basename(file_path)
|
|
737
|
+
if filename in CONFIGURATION_FILES:
|
|
738
|
+
return True
|
|
739
|
+
|
|
740
|
+
extension = get_file_extension(file_path)
|
|
741
|
+
return extension in _EXCLUDED_EXTENSIONS
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
def should_exclude_directory(dir_name: str) -> bool:
|
|
745
|
+
"""Return True if a directory should be skipped entirely during scanning."""
|
|
746
|
+
return dir_name in EXCLUDED_DIRECTORIES
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
# Pre-computed set of extensions excluded from LoC counting
|
|
750
|
+
_EXCLUDED_EXTENSIONS = (
|
|
751
|
+
DOCUMENTATION_FILES | DATA_FILES | BINARY_FILES | MEDIA_FILES | ARCHIVE_FILES | SYSTEM_FILES | SECURITY_FILES
|
|
752
|
+
)
|