Excel Audit Reporting#

Automated Excel SOX/audit report generation for LANspector crawls.

lanspector.reporting.generate_fileshare_report(db, fout, table=None, limit=500, owner=None, subdir=None, per_user=False, acl_skip=None, use_permission_hierarchy=False, skip_files_report=False, skip_old_acl_report=True, skip_user_owner_report=False, strip_pathprefix=None, report_pii=True)[source]#

Generate a multi-sheet Excel SOX/audit and storage-cleanup report.

Produces formatted Excel tables across dedicated worksheets: Summary, No Access to Crawl, ACL membership, parent_vs_child, file_vs_folderACL, Possible PII Locations, Largest Directories, Largest Files, Duplicate Files, Access Time Distribution, Oldest Objects, Largest Users, Backup Files, Backup Paths, and Objects Owned by User. Empty sheets are omitted automatically.

Parameters:
db

A CrawlReader, MultiDB, single database path, or sequence of database paths.

fout

Destination .xlsx workbook path.

table

Crawl timestamp table name (defaults to latest crawl).

limit

Maximum rows written per detail sheet (None or 0 means unlimited).

owner

Optional owner filter for single-user reports.

subdir

Optional subdirectory prefix filter.

per_user

When True, also write one workbook per discovered owner alongside fout.

acl_skip

Optional sequence of (Domain, Name) ACL tuples excluded from permission diffs.

use_permission_hierarchy

Collapse subordinate permissions (MR -> M, F dominates all).

skip_files_report

Omit the file_vs_folderACL sheet when True.

skip_old_acl_report

Omit legacy new perms at child / dropped perms at child sheets when True.

skip_user_owner_report

Omit the Objects Owned by User sheet when True.

strip_pathprefix

Optional prefix stripped from displayed paths.

report_pii

Include the Possible PII Locations worksheet when True.

Returns:
pathlib.Path

Resolved path to the generated Excel workbook.

Parameters:
Return type:

Path

lanspector.reporting.generate_open_shares_summary_report(crawls, fout)[source]#

Generate an Open Shares summary Excel workbook across one or more crawls.

Parameters:
crawls

Directory containing *.db files, a database path, sequence of paths, CrawlReader, or MultiDB.

fout

Destination Excel path (version suffix appended if file already exists).

Returns:
pandas.DataFrame or None

Open shares DataFrame written to fout, or None if no share properties exist.

Parameters:
Return type:

DataFrame | None

lanspector.reporting.scale_bytes_cols(df, columns=None)[source]#

Scale byte-valued columns into human-readable units (KB, MB, GB, TB, …).

Parameters:
df

Input DataFrame (not modified in place).

columns

Specific columns to scale. Defaults to any column named "bytes" or "size".

Returns:
pandas.DataFrame

Copy of df with scaled numeric columns renamed to "<col> [<unit>]".

Parameters:
Return type:

DataFrame

lanspector.reporting.version_adder(path, extension=None)[source]#

Return a non-colliding file path by appending _v00, _v01, … if needed.

Parameters:
path

Desired file path.

extension

Optional extension override (e.g. ".xlsx").

Returns:
pathlib.Path

Original path if unused, otherwise a versioned sibling path.

Parameters:
Return type:

Path

lanspector.reporting.write_excel_table(worksheet, df, startrow=3, startcol=0, header_format=None, table_style='Table Style Medium 2', min_width=8, max_width=60)[source]#

Write df as a formatted Excel Table with auto-sized columns onto worksheet.

Parameters:
worksheet

XlsxWriter worksheet object.

df

DataFrame to write.

startrow

Zero-based top row index for the table header.

startcol

Zero-based left column index.

header_format

Optional XlsxWriter Format applied to header cells.

table_style

Built-in Excel table style name.

min_width

Minimum auto-fitted column width in characters.

max_width

Maximum auto-fitted column width in characters.

Parameters:
Return type:

None