Info for pull request #118 #120
BZanten
started this conversation in
Show and tell
Replies: 2 comments
-
Thank you very much for your work. I'll look into it in the next days. I already created the "last" release of the script version, so before we change to a module people can get the current version. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi Michael
Yes thanks. Below is the text of what I’ve done.
If my changes interfere with other changes, then there is no problem to ignore the pull request, and we can easily re-do the updates in this pull request.
I also just updated the version number, no idea what it should become.
PS regarding version number: you had it in your .ps1 script, - now the .psm1 . but the .psd1 script ALSO specifies the version number (of the whole module itself) you may want to consider changing the version number in both files in future changes.
I have NOT researched how this module can finally be published to the PowerShell gallery or any other gallery where you’d like to have it.
Builtin is of course the PSGallery:
PS C:\Users\ZantenBAM> Get-PSRepository
Name InstallationPolicy SourceLocation
---- ------------------ --------------
PSGallery Untrusted https://www.powershellgallery.com/api/v2
Let’s look at that a later time.
Regards, Ben van Zanten
1. Update “help” in the code
Current code:
.EXAMPLE
Description: HardeningKitty performs an audit, saves the results and creates a log file:
Invoke-HardeningKitty -Mode Audit -Log -Report
Description: HardeningKitty performs an audit with a specific list and does not show machine information:
Invoke-HardeningKitty -FileFindingList .\lists\finding_list_0x6d69636b_user.csv -SkipMachineInformation
Description: HardeningKitty ready only the setting with the default list, and saves the results in a specific file:
Invoke-HardeningKitty -Mode Config -Report -Report C:\tmp\my_hardeningkitty_report.csv
Result:
PS C:\HardeningKitty\windows_hardening.test3> help Invoke-HardeningKitty -Examples
NAME
Invoke-HardeningKitty
SYNOPSIS
Invoke-HardeningKitty - Checks and hardens your Windows configuration
=^._.^=
_( )/ HardeningKitty
Author: Michael Schneider
License: MIT
Required Dependencies: None
Optional Dependencies: None
…-------------------------- EXAMPLE 1 --------------------------
PS C:\>Description: HardeningKitty performs an audit, saves the results and creates a log file:
Invoke-HardeningKitty -Mode Audit -Log -Report
Description: HardeningKitty performs an audit with a specific list and does not show machine information:
Invoke-HardeningKitty -FileFindingList .\lists\finding_list_0x6d69636b_user.csv -SkipMachineInformation
Description: HardeningKitty ready only the setting with the default list, and saves the results in a specific file:
Invoke-HardeningKitty -Mode Config -Report -Report C:\tmp\my_hardeningkitty_report.csv
Note:
* even though you provided 3 examples, only 1 example ' ------ EXAMPLE 1 -------' is outputted
* there is a PS C:\> added before your 'Description' that is not logical
* The FIRST line after the '.EXAMPLE' should be the line with code... (PowerShell will pre-prend this with PS C:\> )
* (All) additional lines after that are treated as, and should be, the description of that example
Updated code for the .Example part:
.EXAMPLE
Invoke-HardeningKitty -Mode Audit -Log -Report
HardeningKitty performs an audit, saves the results and creates a log file
.EXAMPLE
Invoke-HardeningKitty -FileFindingList .\lists\finding_list_0x6d69636b_user.csv -SkipMachineInformation
HardeningKitty performs an audit with a specific list and does not show machine information
.EXAMPLE
Invoke-HardeningKitty -Mode Config -Report -Report C:\tmp\my_hardeningkitty_report.csv
HardeningKitty ready only the setting with the default list, and saves the results in a specific file
Result
PS C:\WINDOWS\system32> Import-module HardeningKitty
PS C:\WINDOWS\system32> get-help Invoke-HardeningKitty -Examples
NAME
Invoke-HardeningKitty
SYNOPSIS
Invoke-HardeningKitty - Checks and hardens your Windows configuration
=^._.^=
_( )/ HardeningKitty
Author: Michael Schneider
License: MIT
Required Dependencies: None
Optional Dependencies: None
-------------------------- EXAMPLE 1 --------------------------
PS C:\>Invoke-HardeningKitty -Mode Audit -Log -Report
HardeningKitty performs an audit, saves the results and creates a log file
-------------------------- EXAMPLE 2 --------------------------
PS C:\>Invoke-HardeningKitty -FileFindingList .\lists\finding_list_0x6d69636b_user.csv -SkipMachineInformation
HardeningKitty performs an audit with a specific list and does not show machine information
-------------------------- EXAMPLE 3 --------------------------
PS C:\>Invoke-HardeningKitty -Mode Config -Report -Report C:\tmp\my_hardeningkitty_report.csv
HardeningKitty ready only the setting with the default list, and saves the results in a specific file
Note that now, there are 3 separate examples, as expected, and each example commandline is pre-fixed with PS C:\>
1. Turn the .PS1 script into a module
* Rename .ps1 to .psm1
I took the liberty to rename the file itself from Invoke-HardeningKitty.ps1 to HardeningKitty because I'm assuming here the PS Module should be called HardeningKitty and the function to invoke is the Invoke-* one.
* add Export-ModuleMember to the end of the script
Export-ModuleMember -Function Invoke-HardeningKitty
* Add a .psd1 script, to describe the metadata of this script.
* Because this rename is quite impactful I also took the liberty to bump the version from 0.8 to 0.9 you may even start to consider it creating it a 1.0 but let's get all in place first.
Note!
you may want to review and update the metadata, especially regarding your names and required license etc. (the GUID is a random new guid generated via New-GUID)
1. Test the Module
* by placing it in the folder:
C:\Program Files\WindowsPowerShell\Modules\HardeningKitty\0.9
* run the script:
PS C:\> Import-Module HardeningKitty
PS C:\> Invoke-HardeningKitty
* Resulting in error:
[!] 8/27/2022 6:29:02 PM - The finding list C:\\lists\finding_list_0x6d69636b_machine.csv was not found.
This is because it is now a Module, it is not normal to 'CD' into the folder where the module is loaded from, so the Invoke- command can't find the input csv file
* Update the code, in 2 places
$CurrentLocation = Get-Location
to
$CurrentLocation = $PSScriptRoot
because $PSScriptRoot is the root of the module that is running, thus the default vulnerability lists are relative to the installed module.
From: Michael Schneider ***@***.***>
Sent: Wednesday, 31 August 2022 07:18
To: 0x6d69636b/windows_hardening ***@***.***>
Cc: Zanten van, BAM (Ben) ***@***.***>; Author ***@***.***>
Subject: Re: [0x6d69636b/windows_hardening] Info for pull request #118 (Discussion #120)
Thank you very much for your work. I'll look into it in the next days. I already created the "last" release of the script version, so before we change to a module people can get the current version.
—
Reply to this email directly, view it on GitHub<#120 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AEOAIKIAPYGWV32E6LVGYLDV33THDANCNFSM6AAAAAAQAZD2LQ>.
You are receiving this because you authored the thread.Message ID: ***@***.******@***.***>>
________________________________
This email (including any attachments to it) is confidential, legally privileged, subject to copyright and is sent for the personal attention of the intended recipient only. If you have received this email in error, please advise us immediately and delete it. You are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. Although we have taken reasonable precautions to ensure no viruses are present in this email, we cannot accept responsibility for any loss or damage arising from the viruses in this email or attachments. We exclude any liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided in this email or its attachments, unless that information is subsequently confirmed in writing. <#rbnl#1898i>
________________________________
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The idea of this pull request is to turn the 'script' into a real module that can be installed like others.
Also (first) updated some logic in the 'help' output.
Current code:
Result:
Note:
• even though you provided 3 examples, only 1 example ' ------ EXAMPLE 1 -------' is outputted
• there is a PS C:> added before your 'Description' that is not logical
• The FIRST line after the '.EXAMPLE' should be the line with code... (PowerShell will pre-prend this with PS C:> )
• (All) additional lines after that are treated as, and should be, the description of that example
Updated code for the .Example part:
So 3x .Example, for each example start with the code, then the explanation
Result
Note that now, there are 3 separate examples, as expected, and each example commandline is pre-fixed with PS C:>
Turned the .PS1 script into a module
a. Rename .ps1 to .psm1
I took the liberty to rename the file itself from Invoke-HardeningKitty.ps1 to HardeningKitty because I'm assuming here the PS Module should be called HardeningKitty and the function to invoke is the Invoke-* one.
b. add Export-ModuleMember to the end of the script
Export-ModuleMember -Function Invoke-HardeningKitty
c. Add a .psd1 script, to describe the metadata of this script.
d. Because this rename is quite impactful I also took the liberty to bump the version from 0.8 to 0.9 you may even start to consider it creating it a 1.0 but let's get all in place first.
Note!
you may want to review and update the metadata, especially regarding your names and required license etc. (the GUID is a random new guid generated via New-GUID)
Tested the Module
a. by placing it in the folder:
C:\Program Files\WindowsPowerShell\Modules\HardeningKitty\0.9
b. run the script:
c. Resulting in error:
d. Update the code, in 2 places
$CurrentLocation = Get-Location
to
$CurrentLocation = $PSScriptRoot
because $PSScriptRoot is the root of the module that is running, thus the default vulnerability lists are relative to the installed module.
Beta Was this translation helpful? Give feedback.
All reactions