aboutsummaryrefslogtreecommitdiff
path: root/databases/sql/passwords/passwords.py
diff options
context:
space:
mode:
authorChristian Cleberg <hello@cleberg.net>2025-05-06 21:54:18 -0500
committerGitHub <noreply@github.com>2025-05-06 21:54:18 -0500
commitf351e70fbdf72ec14f335aa74ad3e7f0bc6da5bc (patch)
tree4a43c4a8f23d001b3277e7668400b8f270946291 /databases/sql/passwords/passwords.py
parent95bf612c338dec8235e89ca6a1d9e5e8cad3f997 (diff)
downloadaudit-tools-f351e70fbdf72ec14f335aa74ad3e7f0bc6da5bc.tar.gz
audit-tools-f351e70fbdf72ec14f335aa74ad3e7f0bc6da5bc.tar.bz2
audit-tools-f351e70fbdf72ec14f335aa74ad3e7f0bc6da5bc.zip
add and update READMEs (#7)
* add and update READMEs * Commit from GitHub Actions (Ruff) --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'databases/sql/passwords/passwords.py')
-rw-r--r--databases/sql/passwords/passwords.py85
1 files changed, 85 insertions, 0 deletions
diff --git a/databases/sql/passwords/passwords.py b/databases/sql/passwords/passwords.py
new file mode 100644
index 0000000..eed41cc
--- /dev/null
+++ b/databases/sql/passwords/passwords.py
@@ -0,0 +1,85 @@
+"""
+Checks SQL Server user data for compliance with Windows policies.
+"""
+
+# Import packages
+import pandas as pd
+
+# Load the data into a pandas DataFrame
+df_input = pd.read_csv("./data.csv")
+
+
+# Function to apply rules and generate report
+def apply_rules_and_report(df):
+ """
+ Apply defined rules against the input data.
+
+ Parameters:
+ df (pandas.DataFrame): SQL login data
+
+ Returns:
+ report (list): List of dictionaries containing test results
+ """
+ report = []
+ for _, row in df.iterrows():
+ result = {
+ "Name": row["name"],
+ "Type Check": "",
+ "Policy Check": "",
+ "Expiration Check": "",
+ "Reason": "",
+ }
+
+ # Check the type_desc
+ if row["type_desc"] == "SQL_LOGIN":
+ result["Type Check"] = "SQL_LOGIN"
+ elif row["type_desc"] == "WINDOWS_LOGIN":
+ result["Type Check"] = "N/A"
+ result["Reason"] = "Refer to Windows password policy."
+ else:
+ result["Type Check"] = "Manual Review"
+ result["Reason"] = "Reviewer to manually review."
+
+ # Check if password policy is enforced
+ if row["is_policy_checked"] == 1:
+ result["Policy Check"] = "PASS"
+ result["Reason"] += """Password policy is enforced. Reviewer to
+ check the assigned policy."""
+ else:
+ result["Policy Check"] = "FAIL"
+ result["Reason"] += "Password policy is not enforced."
+
+ # Check if password expiration is enforced
+ if row["is_expiration_checked"] == 1:
+ result["Expiration Check"] = "PASS"
+ result["Reason"] += """Password expiration is enforced. Reviewer to
+ check the expiration policy."""
+ else:
+ result["Expiration Check"] = "FAIL"
+ result["Reason"] += "Password expiration is not enforced."
+
+ report.append(result)
+
+ return report
+
+
+# Main function to run the script
+def main():
+ """
+ Apply defined rules against the input data and print the results.
+ """
+ # Apply rules and generate report
+ report = apply_rules_and_report(df_input)
+ report_df = pd.DataFrame(report)
+
+ # Do not truncate output
+ pd.set_option("display.expand_frame_repr", True)
+ pd.set_option("display.width", 1000)
+ pd.set_option("display.max_colwidth", 1000)
+
+ # Print the report
+ print(report_df)
+
+
+if __name__ == "__main__":
+ main()