aboutsummaryrefslogtreecommitdiff
path: root/databases/passwords/sql/test.py
diff options
context:
space:
mode:
authorChristian Cleberg <hello@cleberg.net>2024-12-28 11:30:03 -0600
committerChristian Cleberg <hello@cleberg.net>2024-12-28 11:30:03 -0600
commit2ee3e7af7b9133da946dff2643505a3d7013b3c0 (patch)
tree30159ba605abc870507902bcbc53bf6733487476 /databases/passwords/sql/test.py
parentbe74e8cab3bbd8b702adce0127cec2bb48dd7b7b (diff)
downloadaudit-tools-2ee3e7af7b9133da946dff2643505a3d7013b3c0.tar.gz
audit-tools-2ee3e7af7b9133da946dff2643505a3d7013b3c0.tar.bz2
audit-tools-2ee3e7af7b9133da946dff2643505a3d7013b3c0.zip
restructure directories
Diffstat (limited to 'databases/passwords/sql/test.py')
-rw-r--r--databases/passwords/sql/test.py77
1 files changed, 77 insertions, 0 deletions
diff --git a/databases/passwords/sql/test.py b/databases/passwords/sql/test.py
new file mode 100644
index 0000000..bfacb20
--- /dev/null
+++ b/databases/passwords/sql/test.py
@@ -0,0 +1,77 @@
+"""
+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)
+
+ # Print the report
+ print(report_df)
+
+if __name__ == "__main__":
+ main()