ScriptCollection 3.3.23__py3-none-any.whl → 4.0.78__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.
Files changed (47) hide show
  1. ScriptCollection/AnionBuildPlatform.py +206 -0
  2. ScriptCollection/{UpdateCertificates.py → CertificateUpdater.py} +149 -128
  3. ScriptCollection/Executables.py +868 -292
  4. ScriptCollection/GeneralUtilities.py +609 -107
  5. ScriptCollection/ImageUpdater.py +648 -0
  6. ScriptCollection/ProcessesRunner.py +41 -0
  7. ScriptCollection/ProgramRunnerBase.py +47 -42
  8. ScriptCollection/ProgramRunnerMock.py +2 -0
  9. ScriptCollection/ProgramRunnerPopen.py +57 -50
  10. ScriptCollection/ProgramRunnerSudo.py +108 -0
  11. ScriptCollection/SCLog.py +115 -0
  12. ScriptCollection/ScriptCollectionCore.py +2541 -1383
  13. ScriptCollection/TFCPS/Docker/TFCPS_CodeUnitSpecific_Docker.py +95 -0
  14. ScriptCollection/TFCPS/Docker/__init__.py +0 -0
  15. ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationBase.py +8 -0
  16. ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationGenerate.py +6 -0
  17. ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationNoGenerate.py +7 -0
  18. ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py +485 -0
  19. ScriptCollection/TFCPS/DotNet/__init__.py +0 -0
  20. ScriptCollection/TFCPS/Flutter/TFCPS_CodeUnitSpecific_Flutter.py +130 -0
  21. ScriptCollection/TFCPS/Flutter/__init__.py +0 -0
  22. ScriptCollection/TFCPS/Go/TFCPS_CodeUnitSpecific_Go.py +74 -0
  23. ScriptCollection/TFCPS/Go/__init__.py +0 -0
  24. ScriptCollection/TFCPS/NodeJS/TFCPS_CodeUnitSpecific_NodeJS.py +131 -0
  25. ScriptCollection/TFCPS/NodeJS/__init__.py +0 -0
  26. ScriptCollection/TFCPS/Python/TFCPS_CodeUnitSpecific_Python.py +227 -0
  27. ScriptCollection/TFCPS/Python/__init__.py +0 -0
  28. ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py +418 -0
  29. ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnit.py +128 -0
  30. ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py +136 -0
  31. ScriptCollection/TFCPS/TFCPS_CreateRelease.py +95 -0
  32. ScriptCollection/TFCPS/TFCPS_Generic.py +43 -0
  33. ScriptCollection/TFCPS/TFCPS_MergeToMain.py +122 -0
  34. ScriptCollection/TFCPS/TFCPS_MergeToStable.py +350 -0
  35. ScriptCollection/TFCPS/TFCPS_PreBuildCodeunitsScript.py +47 -0
  36. ScriptCollection/TFCPS/TFCPS_Tools_General.py +1356 -0
  37. ScriptCollection/TFCPS/__init__.py +0 -0
  38. {ScriptCollection-3.3.23.dist-info → scriptcollection-4.0.78.dist-info}/METADATA +26 -21
  39. scriptcollection-4.0.78.dist-info/RECORD +43 -0
  40. {ScriptCollection-3.3.23.dist-info → scriptcollection-4.0.78.dist-info}/WHEEL +1 -1
  41. scriptcollection-4.0.78.dist-info/entry_points.txt +64 -0
  42. ScriptCollection/Hardening.py +0 -59
  43. ScriptCollection/ProgramRunnerEpew.py +0 -122
  44. ScriptCollection/TasksForCommonProjectStructure.py +0 -1170
  45. ScriptCollection-3.3.23.dist-info/RECORD +0 -15
  46. ScriptCollection-3.3.23.dist-info/entry_points.txt +0 -24
  47. {ScriptCollection-3.3.23.dist-info → scriptcollection-4.0.78.dist-info}/top_level.txt +0 -0
File without changes
@@ -1,17 +1,17 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: ScriptCollection
3
- Version: 3.3.23
3
+ Version: 4.0.78
4
4
  Summary: The ScriptCollection is the place for reusable scripts.
5
5
  Home-page: https://github.com/anionDev/ScriptCollection
6
6
  Author: Marius Göcke
7
7
  Author-email: marius.goecke@gmail.com
8
- Project-URL: Documentation, https://github.com/anionDev/ScriptCollection/blob/main/ScriptCollection/Other/Reference/ReferenceContent/index.md
8
+ Project-URL: Documentation, https://aniondev.github.io/ScriptCollectionReference/index.html
9
9
  Project-URL: Changelog, https://github.com/anionDev/ScriptCollection/tree/main/Other/Resources/Changelog
10
10
  Keywords: package release build management
11
11
  Classifier: Intended Audience :: Developers
12
12
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
13
13
  Classifier: Programming Language :: Python :: 3.10
14
- Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
15
15
  Classifier: Operating System :: POSIX :: Linux
16
16
  Classifier: Operating System :: Microsoft :: Windows :: Windows 10
17
17
  Classifier: Topic :: System :: Logging
@@ -22,18 +22,27 @@ Classifier: Topic :: Terminals
22
22
  Classifier: Topic :: Utilities
23
23
  Requires-Python: >=3.10
24
24
  Description-Content-Type: text/markdown
25
- Requires-Dist: build (>=0.9.0)
26
- Requires-Dist: defusedxml (>=0.7.1)
27
- Requires-Dist: keyboard (>=0.13.5)
28
- Requires-Dist: lxml (>=4.9.1)
29
- Requires-Dist: ntplib (>=0.4.0)
30
- Requires-Dist: pycdlib (>=1.13.0)
31
- Requires-Dist: pylint (>=2.15.5)
32
- Requires-Dist: PyPDF2 (>=2.11.1)
33
- Requires-Dist: pytest (>=7.2.0)
34
- Requires-Dist: qrcode (>=7.3.1)
35
- Requires-Dist: send2trash (>=1.8.0)
36
- Requires-Dist: xmlschema (>=2.1.1)
25
+ Requires-Dist: build>=1.3.0
26
+ Requires-Dist: coverage>=7.11.3
27
+ Requires-Dist: cyclonedx-bom>=7.1.0
28
+ Requires-Dist: defusedxml>=0.7.1
29
+ Requires-Dist: keyboard>=0.13.5
30
+ Requires-Dist: lcov-cobertura>=2.1.1
31
+ Requires-Dist: lxml>=6.0.1
32
+ Requires-Dist: ntplib>=0.4.0
33
+ Requires-Dist: Pillow>=11.3.0
34
+ Requires-Dist: psutil>=7.1.3
35
+ Requires-Dist: pycdlib>=1.14.0
36
+ Requires-Dist: Pygments>=2.19.2
37
+ Requires-Dist: pylint>=4.0.2
38
+ Requires-Dist: pyOpenSSL>=25.3.0
39
+ Requires-Dist: PyPDF>=6.2.0
40
+ Requires-Dist: pytest>=8.4.2
41
+ Requires-Dist: PyYAML>=6.0.3
42
+ Requires-Dist: qrcode>=8.2.0
43
+ Requires-Dist: send2trash>=1.8.3
44
+ Requires-Dist: twine>=6.2.0
45
+ Requires-Dist: xmlschema>=4.2.0
37
46
 
38
47
  # ScriptCollection
39
48
 
@@ -47,10 +56,6 @@ Requires-Dist: xmlschema (>=2.1.1)
47
56
  [![Downloads](https://pepy.tech/badge/scriptcollection)](https://pepy.tech/project/scriptcollection)
48
57
  ![Coverage](https://raw.githubusercontent.com/anionDev/ScriptCollection/main/ScriptCollection/Other/Resources/TestCoverageBadges/badge_shieldsio_linecoverage_blue.svg)
49
58
 
50
- ![License](https://img.shields.io/badge/license-MIT-blue)
51
- ![GitHub last commit](https://img.shields.io/github/last-commit/anionDev/ScriptCollection)
52
- ![GitHub issues](https://img.shields.io/github/issues-raw/anionDev/ScriptCollection)
53
-
54
59
  The ScriptCollection is the place for reusable scripts.
55
60
 
56
61
  ## Reference
@@ -63,7 +68,7 @@ Most of the scripts are written in [python](https://www.python.org) 3.
63
68
 
64
69
  Caution: Before executing **any** script of this repository read the sourcecode of the script (and the sourcecode of all functions called by this function directly or transitively) carefully and verify that the script does exactly what you want to do and nothing else.
65
70
 
66
- Some functions are not entirely available on windows or require common third-party tools. See the [Runtime dependencies](#Runtime-dependencies)-section for more information.
71
+ Some functions are not entirely available on windows or require common third-party tools. See the [Runtime dependencies](#runtime-dependencies)-section for more information.
67
72
 
68
73
  When using ScriptCollection it is not required but recommended for better usability to have [epew](https://github.com/anionDev/Epew) installed.
69
74
 
@@ -0,0 +1,43 @@
1
+ ScriptCollection/AnionBuildPlatform.py,sha256=zTQ-2g2YKFw0_majaQVknslAnNUAotuQhHtB4W20ds4,12663
2
+ ScriptCollection/CertificateUpdater.py,sha256=GXPxmYaW-ufOqsiP9kUYdtI6eNg1-GzrrCqsZdwW_HY,9199
3
+ ScriptCollection/Executables.py,sha256=oAC4lr7V0DF3fHabk44cKVkEiIMt5761VPYYHeme0kQ,42066
4
+ ScriptCollection/GeneralUtilities.py,sha256=dYMtLShbN5FcNgdUHcnWRnlH0oxXntSzRp2WEVdXIKU,53512
5
+ ScriptCollection/ImageUpdater.py,sha256=0KPybKb_9IALhSTNflST-mewQVZ4kvXzNtfcN0-Ut8k,29215
6
+ ScriptCollection/ProcessesRunner.py,sha256=3mu4ZxzZleQo0Op6o9EYTCFiJfb6kx5ov2YfZfT89mU,1395
7
+ ScriptCollection/ProgramRunnerBase.py,sha256=4A2eQgSg_rRgQcgSi-LYtUlM-uSQEpS7qFWn0tWt4uo,2171
8
+ ScriptCollection/ProgramRunnerMock.py,sha256=uTu-aFle1W_oKjeQEmuPsFPQpvo0kRf2FrRjAPIwT5Y,37
9
+ ScriptCollection/ProgramRunnerPopen.py,sha256=BPY7-ZMIlqT7JOKz8qlB5c0laF2Js-ijzqk09GxZC48,3821
10
+ ScriptCollection/ProgramRunnerSudo.py,sha256=_khC3xuTdrPoLluBJZWfldltmmuKltABJPcbjZSFW-4,4835
11
+ ScriptCollection/SCLog.py,sha256=fNi-7pcoXoYiAHUNvqeZQ-I-nW8vLuu4NHs3DP31I58,4529
12
+ ScriptCollection/ScriptCollectionCore.py,sha256=fPaBNaTzLyvG2PKjjpA5uJhV5ySpan_-7jNRlM_ZbMU,142599
13
+ ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
+ ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py,sha256=yi33pwy2bNvUAo5V6t5aIPAAWAKzFWBNps7yTOPXmNI,26253
15
+ ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnit.py,sha256=XTL6MO-LTytDBYz9zv3LcmeG2-IDDvyxbfrFctS5-0A,7458
16
+ ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=f9oGnopuzn3iDHC1AksU7Qr60LbDe0eLjYeXGiDPhAk,7526
17
+ ScriptCollection/TFCPS/TFCPS_CreateRelease.py,sha256=bcJlfI062Eoq7MOIhun-_iNG7SdO1ZIuC_cylaoLI1s,6332
18
+ ScriptCollection/TFCPS/TFCPS_Generic.py,sha256=O-0guM_LJCcZmPZJhMgTvXD2RXUJEBWWv6Bt6hDFhvM,1943
19
+ ScriptCollection/TFCPS/TFCPS_MergeToMain.py,sha256=7F9cwFy-7bxN5mkK9V_n7ffMPvBxLwzQvrAe60fbEMM,7245
20
+ ScriptCollection/TFCPS/TFCPS_MergeToStable.py,sha256=nNS8NavE7MKUOkisH5h8RZa9dcHQd5r8yFZWO4RQSpY,21645
21
+ ScriptCollection/TFCPS/TFCPS_PreBuildCodeunitsScript.py,sha256=CxdwUklhZVuJGp0vcokoH_KMXFzmlUlZwj77xFYijho,2242
22
+ ScriptCollection/TFCPS/TFCPS_Tools_General.py,sha256=F2L235oY-Da4zES8fEjgEYEhrSFVEWunrfCOHfBgms8,86042
23
+ ScriptCollection/TFCPS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
+ ScriptCollection/TFCPS/Docker/TFCPS_CodeUnitSpecific_Docker.py,sha256=-KanDRK2e-nXCJj10cotsZkBc9L8VuFRd1mfFhzLJ8o,5552
25
+ ScriptCollection/TFCPS/Docker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
+ ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationBase.py,sha256=bT6Gd5pQpZCw4OQz6HWkPCSn5z__eUUEisABLDSxd0o,200
27
+ ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationGenerate.py,sha256=QyjOfMY22JWCvKjMelHiDWbJiWqotOfebpJpgDUaoO4,237
28
+ ScriptCollection/TFCPS/DotNet/CertificateGeneratorInformationNoGenerate.py,sha256=i0zEGehj0sttxjjZtoq2KFSKp_ulxVyWp_ZgAhIY_So,241
29
+ ScriptCollection/TFCPS/DotNet/TFCPS_CodeUnitSpecific_DotNet.py,sha256=Ubcr9WyDJkQCJOuiTj1pwUiUEKQY6l74mdXSx4N0sMA,31140
30
+ ScriptCollection/TFCPS/DotNet/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
+ ScriptCollection/TFCPS/Flutter/TFCPS_CodeUnitSpecific_Flutter.py,sha256=Va1DRur-AsU31ywy0-QbgCJs8oCTIf0iYPszEw-kXYs,7155
32
+ ScriptCollection/TFCPS/Flutter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
+ ScriptCollection/TFCPS/Go/TFCPS_CodeUnitSpecific_Go.py,sha256=vA33nDlFsDXhkt7SePVnOCYYlkDsNj94VZdCTtFV57w,3467
34
+ ScriptCollection/TFCPS/Go/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
+ ScriptCollection/TFCPS/NodeJS/TFCPS_CodeUnitSpecific_NodeJS.py,sha256=jOmWQDQdygAgS9QZYqsgiKC9zmmFY7TBjYoc3FVgMSY,6908
36
+ ScriptCollection/TFCPS/NodeJS/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
+ ScriptCollection/TFCPS/Python/TFCPS_CodeUnitSpecific_Python.py,sha256=LoBL_CJe4uf-2ovXxj0f-lgW8sktegWoeuFxFrZgcFE,12798
38
+ ScriptCollection/TFCPS/Python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
+ scriptcollection-4.0.78.dist-info/METADATA,sha256=t_3ssziQg8pbebTwlit5W17RwvAwpH7s7m2-kIHOxi0,7690
40
+ scriptcollection-4.0.78.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
41
+ scriptcollection-4.0.78.dist-info/entry_points.txt,sha256=_izhaQEyHiyBIfM2zTYDaJ7qvgsP1WntkVChFnkWymE,4431
42
+ scriptcollection-4.0.78.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
43
+ scriptcollection-4.0.78.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.38.4)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -0,0 +1,64 @@
1
+ [console_scripts]
2
+ scappendlinetofile = ScriptCollection.Executables:AppendLineToFile
3
+ scbuildcodeunit = ScriptCollection.Executables:BuildCodeUnit
4
+ scbuildcodeunits = ScriptCollection.Executables:BuildCodeUnits
5
+ scbuildcodeunitsc = ScriptCollection.Executables:BuildCodeUnitsC
6
+ sccalculatebitcoinblockhash = ScriptCollection.Executables:CalculateBitcoinBlockHash
7
+ scchangefileextension = ScriptCollection.Executables:ChangeFileExtensions
8
+ scchangehashofprogram = ScriptCollection.Executables:ChangeHashOfProgram
9
+ sccleantoolscache = ScriptCollection.Executables:CleanToolsCache
10
+ scconvertgitrepositorytobarerepository = ScriptCollection.Executables:ConvertGitRepositoryToBareRepository
11
+ sccopy = ScriptCollection.Executables:Copy
12
+ sccreatechangelogentry = ScriptCollection.Executables:CreateChangelogEntry
13
+ sccreateemptyfilewithspecificsize = ScriptCollection.Executables:CreateEmptyFileWithSpecificSize
14
+ sccreatefile = ScriptCollection.Executables:CreateFile
15
+ sccreatefolder = ScriptCollection.Executables:CreateFolder
16
+ sccreatehashofallfiles = ScriptCollection.Executables:CreateHashOfAllFiles
17
+ sccreateisofilewithobfuscatedfiles = ScriptCollection.Executables:CreateISOFileWithObfuscatedFiles
18
+ sccreaterelease = ScriptCollection.Executables:CreateRelease
19
+ sccreatesimplemergewithoutrelease = ScriptCollection.Executables:CreateSimpleMergeWithoutRelease
20
+ sccurrentuserhaselevatedprivileges = ScriptCollection.Executables:CurrentUserHasElevatedPrivileges
21
+ scespoc = ScriptCollection.Executables:Espoc
22
+ scextractpdfpages = ScriptCollection.Executables:ExtractPDFPages
23
+ scfilecontainscontent = ScriptCollection.Executables:FileContainsContent
24
+ scfileexists = ScriptCollection.Executables:FileExists
25
+ scfilenameobfuscator = ScriptCollection.Executables:FilenameObfuscator
26
+ scfolderexists = ScriptCollection.Executables:FolderExists
27
+ scforeach = ScriptCollection.Executables:ForEach
28
+ scgeneratearc42referencetemplate = ScriptCollection.Executables:GenerateARC42ReferenceTemplate
29
+ scgeneratecertificate = ScriptCollection.Executables:GenerateCertificate
30
+ scgeneratecertificateauthority = ScriptCollection.Executables:GenerateCertificateAuthority
31
+ scgeneratecertificatesignrequest = ScriptCollection.Executables:GenerateCertificateSignRequest
32
+ scgeneratesnkfiles = ScriptCollection.Executables:GenerateSnkFiles
33
+ scgeneratethumbnail = ScriptCollection.Executables:GenerateThumbnail
34
+ schealthcheck = ScriptCollection.Executables:Healthcheck
35
+ sckeyboarddiagnosis = ScriptCollection.Executables:KeyboardDiagnosis
36
+ sclistfoldercontent = ScriptCollection.Executables:ListFolderContent
37
+ scloc = ScriptCollection.Executables:LOC
38
+ scmergepdfs = ScriptCollection.Executables:MergePDFs
39
+ scnpmi = ScriptCollection.Executables:NpmI
40
+ scobfuscatefilesfolder = ScriptCollection.Executables:ObfuscateFilesFolder
41
+ scocranalysisoffile = ScriptCollection.Executables:OCRAnalysisOfFile
42
+ scocranalysisoffolder = ScriptCollection.Executables:OCRAnalysisOfFolder
43
+ scocranalysisofrepository = ScriptCollection.Executables:OCRAnalysisOfRepository
44
+ scorganizelinesinfile = ScriptCollection.Executables:OrganizeLinesInFile
45
+ scpdftoimage = ScriptCollection.Executables:PDFToImage
46
+ scprintcurrentworkingdirectory = ScriptCollection.Executables:PrintCurrecntWorkingDirectory
47
+ scprintfilecontent = ScriptCollection.Executables:PrintFileContent
48
+ scprintfilesize = ScriptCollection.Executables:PrintFileSize
49
+ scprintosname = ScriptCollection.Executables:PrintOSName
50
+ scregexreplaceinfile = ScriptCollection.Executables:RegexReplaceInFile
51
+ scremovefile = ScriptCollection.Executables:RemoveFile
52
+ scremovefolder = ScriptCollection.Executables:RemoveFolder
53
+ screname = ScriptCollection.Executables:Rename
54
+ screplacesubstringsinfilenames = ScriptCollection.Executables:ReplaceSubstringsInFilenames
55
+ scsearchinfiles = ScriptCollection.Executables:SearchInFiles
56
+ scsetcontentoffile = ScriptCollection.Executables:SetContentOfFile
57
+ scshow2faasqrcode = ScriptCollection.Executables:Show2FAAsQRCode
58
+ scshowmissingfiles = ScriptCollection.Executables:ShowMissingFiles
59
+ scsigncertificate = ScriptCollection.Executables:SignCertificate
60
+ scupdatedependencies = ScriptCollection.Executables:UpdateDependencies
61
+ scupdateimagesindockercomposefile = ScriptCollection.Executables:UpdateImagesInDockerComposeFile
62
+ scupdatenugetpackagesincsharpproject = ScriptCollection.Executables:UpdateNugetpackagesInCsharpProject
63
+ scupdatetimestampinfile = ScriptCollection.Executables:UpdateTimestampInFile
64
+ scuploadfile = ScriptCollection.Executables:UploadFile
@@ -1,59 +0,0 @@
1
- import traceback
2
- from .GeneralUtilities import GeneralUtilities
3
- from .ScriptCollectionCore import ScriptCollectionCore
4
-
5
-
6
- class HardeningScript:
7
-
8
- __sc: ScriptCollectionCore = ScriptCollectionCore()
9
- __applicationstokeep: "list[str]" = None
10
- __additionalfolderstoremove: "list[str]" = None
11
- __applicationstodelete: "list[str]" = [
12
- "git", "curl", "wget", "sudo", "sendmail", "net-tools", "nano", "lsof", "tcpdump",
13
- "unattended-upgrades", "mlocate", "gpg", "htop", "netcat", "gcc-10", "gdb", "perl-modules-*",
14
- "binutils-common", "bash", "tar", "vi"
15
- ]
16
-
17
- def __init__(self, applicationstokeep, additionalfoldertoremove):
18
- self.__applicationstokeep = GeneralUtilities.to_list(applicationstokeep, ";")
19
- self.__additionalfolderstoremove = GeneralUtilities.to_list(additionalfoldertoremove, ";")
20
-
21
- @GeneralUtilities.check_arguments
22
- def run(self):
23
- try:
24
- GeneralUtilities.write_message_to_stdout("Hardening-configuration:")
25
- GeneralUtilities.write_message_to_stdout(f" applicationstokeep: {self.__applicationstokeep}")
26
- GeneralUtilities.write_message_to_stdout(f" additionalFolderToRemove: {self.__additionalfolderstoremove}")
27
-
28
- # TODO:
29
- # - kill applications which opens undesired ports
30
- # - generally disable root-login
31
- # - prevent creating/writing files using something like "echo x > y"
32
- # - prevent reading from files as much as possible
33
- # - prevent executing files as much as possible
34
- # - shrink rights of all user as much as possible
35
- # - deinstall/disable find, chown, chmod, apt etc. and all other applications which are not listed in $applicationstokeep
36
- # - disable unnecessary services/daemons if available (e. g. "systemctl disable avahi-daemon")
37
- # etc.
38
- # general idea: remove as much as possible from the file-system. all necessary binaries should already be available in the RAM usually.
39
-
40
- # Remove undesired folders
41
- for additionalfoldertoremove in self.__additionalfolderstoremove:
42
- GeneralUtilities.write_message_to_stdout(f"Remove folder {additionalfoldertoremove}...")
43
- GeneralUtilities.ensure_directory_does_not_exist(additionalfoldertoremove)
44
-
45
- # Remove undesired packages
46
- for applicationtodelete in self.__applicationstodelete:
47
- if not applicationtodelete in self.__applicationstokeep and self.__package_is_installed(applicationtodelete):
48
- GeneralUtilities.write_message_to_stdout(f"Remove application {applicationtodelete}...")
49
- self.__execute("apt-get", f"purge -y {applicationtodelete}")
50
- except Exception as exception:
51
- GeneralUtilities.write_exception_to_stderr_with_traceback(exception, traceback, "Exception occurred while hardening.")
52
-
53
- @GeneralUtilities.check_arguments
54
- def __package_is_installed(self, package: str) -> bool:
55
- return True # TODO see https://askubuntu.com/questions/660305/how-to-tell-if-a-certain-package-exists-in-the-apt-repos
56
-
57
- @GeneralUtilities.check_arguments
58
- def __execute(self, program: str, argument: str, workding_directory: str = None):
59
- return self.__sc.run_program(program, argument, workding_directory)
@@ -1,122 +0,0 @@
1
- import os
2
- import base64
3
- import tempfile
4
- from subprocess import Popen
5
- from uuid import uuid4
6
-
7
- from .GeneralUtilities import GeneralUtilities
8
- from .ProgramRunnerBase import ProgramRunnerBase
9
- from .ProgramRunnerPopen import ProgramRunnerPopen
10
-
11
-
12
- class CustomEpewArgument:
13
-
14
- print_errors_as_information: bool
15
- log_file: str
16
- timeoutInSeconds: int
17
- addLogOverhead: bool
18
- title: str
19
- log_namespace: str
20
- verbosity: int
21
- arguments_for_log: list[str]
22
- tempdir = os.path.join(tempfile.gettempdir(), str(uuid4()))
23
- stdoutfile = tempdir + ".epew.stdout.txt"
24
- stderrfile = tempdir + ".epew.stderr.txt"
25
- exitcodefile = tempdir + ".epew.exitcode.txt"
26
- pidfile = tempdir + ".epew.pid.txt"
27
-
28
- def __init__(self, print_errors_as_information: bool, log_file: str, timeoutInSeconds: int, addLogOverhead: bool, title: str, log_namespace: str, verbosity: int, arguments_for_log: list[str]):
29
- self.print_errors_as_information = print_errors_as_information
30
- self.log_file = log_file
31
- self.timeoutInSeconds = timeoutInSeconds
32
- self.addLogOverhead = addLogOverhead
33
- self.title = title
34
- self.log_namespace = log_namespace
35
- self.verbosity = verbosity
36
- self.arguments_for_log = arguments_for_log
37
-
38
-
39
- class ProgramRunnerEpew(ProgramRunnerBase):
40
-
41
- @GeneralUtilities.check_arguments
42
- def run_program_argsasarray_async_helper(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None) -> Popen:
43
- if GeneralUtilities.epew_is_available():
44
- custom_argument: CustomEpewArgument = custom_argument
45
- args = []
46
-
47
- base64argument = base64.b64encode(' '.join(arguments_as_array).encode('utf-8')).decode('utf-8')
48
- args.append(f'-p "{program}"')
49
- args.append(f'-a {base64argument}')
50
- args.append('-b')
51
- args.append(f'-w "{working_directory}"')
52
- if custom_argument.stdoutfile is not None:
53
- args.append(f'-o {custom_argument.stdoutfile}')
54
- if custom_argument.stderrfile is not None:
55
- args.append(f'-e {custom_argument.stderrfile}')
56
- if custom_argument.exitcodefile is not None:
57
- args.append(f'-x {custom_argument.exitcodefile}')
58
- if custom_argument.pidfile is not None:
59
- args.append(f'-r {custom_argument.pidfile}')
60
- args.append(f'-d {str(custom_argument.timeoutInSeconds*1000)}')
61
- args.append(f'-t "{custom_argument.title}"')
62
- args.append(f'-l "{custom_argument.log_namespace}"')
63
- if not GeneralUtilities.string_is_none_or_whitespace(custom_argument.log_file):
64
- args.append(f'-f "{custom_argument.log_file}"')
65
- if custom_argument.print_errors_as_information:
66
- args.append("-i")
67
- if custom_argument.addLogOverhead:
68
- args.append("-g")
69
- args.append("-v "+str(custom_argument.verbosity))
70
- return ProgramRunnerPopen().run_program_argsasarray_async_helper("epew", args, working_directory)
71
- else:
72
- raise ValueError("Epew is not available.")
73
-
74
- # Return-values program_runner: Exitcode, StdOut, StdErr, Pid
75
- @GeneralUtilities.check_arguments
76
- def wait(self, process: Popen, custom_argument: object = None) -> tuple[int, str, str, int]:
77
- process.wait()
78
- custom_argument: CustomEpewArgument = custom_argument
79
- stdout = self.__load_text(custom_argument.output_file_for_stdout)
80
- stderr = self.__load_text(custom_argument.output_file_for_stderr)
81
- exit_code = self.__get_number_from_filecontent(self.__load_text(custom_argument.output_file_for_exit_code))
82
- pid = self.__get_number_from_filecontent(self.__load_text(custom_argument.output_file_for_pid))
83
- GeneralUtilities.ensure_directory_does_not_exist(custom_argument.tempdir)
84
- result = (exit_code, stdout, stderr, pid)
85
- return result
86
-
87
- @GeneralUtilities.check_arguments
88
- def run_program_argsasarray(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None) -> tuple[int, str, str, int]:
89
- process: Popen = self.run_program_argsasarray_async_helper(program, arguments_as_array, working_directory, custom_argument)
90
- return self.wait(process, custom_argument)
91
-
92
- @GeneralUtilities.check_arguments
93
- def run_program(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None) -> tuple[int, str, str, int]:
94
- return self.run_program_argsasarray(program, GeneralUtilities.arguments_to_array(arguments), working_directory, custom_argument)
95
-
96
- @GeneralUtilities.check_arguments
97
- def run_program_argsasarray_async(self, program: str, arguments_as_array: list[str] = [], working_directory: str = None, custom_argument: object = None) -> int:
98
- return self.run_program_argsasarray_async_helper(program, arguments_as_array, working_directory, custom_argument).pid
99
-
100
- @GeneralUtilities.check_arguments
101
- def run_program_async(self, program: str, arguments: str = "", working_directory: str = None, custom_argument: object = None) -> int:
102
- return self.run_program_argsasarray_async(program, GeneralUtilities.arguments_to_array(arguments), working_directory, custom_argument)
103
-
104
- @GeneralUtilities.check_arguments
105
- def __get_number_from_filecontent(self, filecontent: str) -> int:
106
- for line in filecontent.splitlines():
107
- try:
108
- striped_line = GeneralUtilities.strip_new_line_character(line)
109
- result = int(striped_line)
110
- return result
111
- except:
112
- pass
113
- raise Exception(f"'{filecontent}' does not containe an int-line")
114
-
115
- @GeneralUtilities.check_arguments
116
- def __load_text(self, file: str) -> str:
117
- if os.path.isfile(file):
118
- content = GeneralUtilities.read_text_from_file(file).replace('\r', '')
119
- os.remove(file)
120
- return content
121
- else:
122
- raise Exception(f"File '{file}' does not exist")