-
Notifications
You must be signed in to change notification settings - Fork 709
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve template pam_account_password_faillock
Added template to docs. Defined requirements for variables in template.py: - ext_variable must be defined since it is used in the remediation - bounding variables must be 'use_ext_variable', (int), or undefined (if undefined, bounding variables are initialized to None) Cleaned up the OVAL: - fix conditionals to consistently use inclusive comparisons instead of inclusive for ext_variable, and exclusive for numbers - remove conditionals which compare to `var_ref="{{{ VARIABLE_*_BOUND}}}"` as these variables don't exist in the OVAL - modify check for undefined variable to compare to jinja test none
- Loading branch information
Showing
3 changed files
with
48 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
shared/templates/pam_account_password_faillock/template.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
def preprocess(data, lang): | ||
if data.get("ext_variable") is None: | ||
errmsg = ("The template instance of the rule {0} requires the " | ||
"ext_variable to be defined".format(_rule_id)) | ||
raise ValueError(errmsg) | ||
|
||
for var in ["variable_upper_bound", "variable_lower_bound"]: | ||
data[var] = data.get(var, None) | ||
if data.get(var) is not None and \ | ||
data.get(var) != "use_ext_variable" and \ | ||
type(data.get(var)) != int: | ||
errmsg = ("The template instance of the rule {0} requires the " | ||
"parameter {1} is either 'use_ext_variable' or " | ||
"a number or undefined".formate(_rule_id, var)) | ||
raise ValueError(errmsg) | ||
return data |