Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default argument values in Generate Password #29203

Merged
merged 4 commits into from Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions Packs/CommonScripts/ReleaseNotes/1_12_17.md
@@ -0,0 +1,7 @@

#### Scripts

##### GeneratePassword

- Fixed an issue where no correct default values were given for max_* arguments.
yaakovpraisler marked this conversation as resolved.
Show resolved Hide resolved
- Updated the Docker image to: *demisto/python3:3.10.12.68714*.
16 changes: 8 additions & 8 deletions Packs/CommonScripts/Scripts/GeneratePassword/GeneratePassword.py
Expand Up @@ -28,14 +28,14 @@ def print_char_values(pw):

def generate_password(args: Dict[str, Any]) -> CommandResults:
is_debug = argToBoolean(args.get('debug'))
min_lowercase = arg_to_number(args.get('min_lcase')) or DEFAULT_MIN
max_lowercase = arg_to_number(args.get('max_lcase')) or DEFAULT_MAX
min_uppercase = arg_to_number(args.get('min_ucase')) or DEFAULT_MIN
max_uppercase = arg_to_number(args.get('max_ucase')) or DEFAULT_MAX
min_digits = arg_to_number(args.get('min_digits')) or DEFAULT_MIN
max_digits = arg_to_number(args.get('max_digits')) or DEFAULT_MAX
min_symbols = arg_to_number(args.get('min_symbols')) or DEFAULT_MIN
max_symbols = arg_to_number(args.get('max_symbols')) or DEFAULT_MAX
min_lowercase = arg_to_number(args.get('min_lcase', DEFAULT_MIN))
max_lowercase = arg_to_number(args.get('max_lcase', DEFAULT_MAX))
min_uppercase = arg_to_number(args.get('min_ucase', DEFAULT_MIN))
max_uppercase = arg_to_number(args.get('max_ucase', DEFAULT_MAX))
min_digits = arg_to_number(args.get('min_digits', DEFAULT_MIN))
max_digits = arg_to_number(args.get('max_digits', DEFAULT_MAX))
min_symbols = arg_to_number(args.get('min_symbols', DEFAULT_MIN))
max_symbols = arg_to_number(args.get('max_symbols', DEFAULT_MAX))

if min(min_uppercase, min_lowercase, min_digits, min_symbols) < 0:
raise DemistoException("All numeral arguments must be positive.")
Expand Down
Expand Up @@ -5,7 +5,7 @@ name: GeneratePassword
script: ''
type: python
subtype: python3
dockerimage: demisto/python3:3.10.12.66339
dockerimage: demisto/python3:3.10.12.68714
tags:
- Utility
comment: "This function generates a password and allows various parameters to customize the properties of the password depending on the use case (e.g. password complexity requirements). The default behavior is to generate a password of *random length* including all four character classes (upper, lower, digits, symbols) with at least five and at most ten characters per class. \n\nThe min_* values all default to 0. This means that if the command is executed in this way:\n!GeneratePassword max_lcase=10\nIt is possible that a password of length zero could be generated. It is therefore recommended to always include a min_* parameter that matches. \n\nThe debug parameter will print certain properties of the command into the WarRoom for easy diagnostics."
Expand Down
Expand Up @@ -32,6 +32,7 @@ def does_password_meet_requirement(
[
(1, 2, 1, 2, 1, 2, 1, 2), # Test case with all ranges set to 1-2
(2, 5, 3, 5, 4, 6, 1, 3), # Test case with various ranges
(2, 5, 3, 5, 4, 10, 0, 0), # Test case with no symbols
]
)
def test_generate_password(
Expand Down
2 changes: 1 addition & 1 deletion Packs/CommonScripts/pack_metadata.json
Expand Up @@ -2,7 +2,7 @@
"name": "Common Scripts",
"description": "Frequently used scripts pack.",
"support": "xsoar",
"currentVersion": "1.12.16",
"currentVersion": "1.12.17",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down