Settings, Constants & Data Types#
Dataclass configuration models for the lanspector CLI.
Parsed automatically by jsonargparse, supporting both command-line flags
and YAML/JSON configuration files (--config).
- class lanspector.settings.CrawlSettings(path=None, fout=None, driver=None, driver_out=None, dryrun=False, scantype='fd', permissions=True, crawl_acls=True, max_md5=None, skip_size=False, limit=0, max_depth=0, detect_pii=False, use_ner=False, summarize=True, sunburst_html=None, resume=False, n_procs=None, log_level='INFO')[source]#
Bases:
objectCrawl a directory/fileshare (
--path) or batch target list (--driver).Provide either
--path(single folder or UNC share) or--driver(batch file of paths/servers/domains). When--foutis omitted on the CLI, output defaults to./<target>.dbin the current working directory and an Excel audit summary report is written alongside it (--summarize true).- Attributes:
- path
Root directory or UNC fileshare path to crawl (required unless
--driveris set).- fout
Output database or file path (
.db,.sqlite,.sqlite3,.csv,.xlsx). Defaults to./<target>.dbin the current working directory when omitted.- driver
Optional text driver file listing paths, server names, or
DN: <Domain>entries for parallel multi-share crawling.- driver_out
Directory to store per-share crawl databases when
driveris specified.- dryrun
When used with
driver, discover targets without crawling them.- scantype
Objects to harvest:
d(directories),f(files), orfd(both).- permissions
Harvest NTFS/POSIX effective permissions for each crawled object.
- crawl_acls
Query Active Directory for group membership of discovered ACLs (Windows only).
- max_md5
Compute MD5 checksums for files smaller than this threshold in bytes (
Nonedisables).- skip_size
Skip aggregating file sizes inside directories when
scantype='d'.- limit
Stop crawling after this many objects (
0means unlimited).- max_depth
Stop crawling after this many directory levels below
path(0means unlimited).- detect_pii
Inspect supported file contents (
.txt,.csv,.xlsx) for PII indicators.- use_ner
Enable optional NLTK named-entity recognition during PII content scanning.
- summarize
Generate a formatted Excel audit report alongside the SQLite database (default
True).- sunburst_html
Optional path to export a standalone interactive Plotly storage sunburst HTML file.
- resume
Resume an interrupted crawl (where
scan_endisNULLinCRAWL_INFO) infout, skipping already-persisted directories and files.- n_procs
Maximum concurrent crawl worker processes in
drivermode.- log_level
Loguru logging verbosity.
- Parameters:
path (Path | None)
fout (Path | None)
driver (Path | None)
driver_out (Path | None)
dryrun (bool)
scantype (Literal['d', 'f', 'fd'])
permissions (bool)
crawl_acls (bool)
max_md5 (int | None)
skip_size (bool)
limit (int)
max_depth (int)
detect_pii (bool)
use_ner (bool)
summarize (bool)
sunburst_html (Path | None)
resume (bool)
n_procs (int | None)
log_level (Literal['ERROR', 'WARNING', 'INFO', 'DEBUG', 'TRACE'])
- class lanspector.settings.CompareSettings(database, table_before=None, table_after=None, output=None, subdir=None, log_level='INFO')[source]#
Bases:
objectConfiguration for
lanspector compare.- Attributes:
- database
Path to a LANspector SQLite crawl database containing at least two crawls.
- table_before
Earlier crawl table name (defaults to second-most-recent crawl).
- table_after
Later crawl table name (defaults to most-recent crawl).
- output
Optional Excel workbook path to export permission and file diffs.
- subdir
Optional subdirectory prefix to restrict comparison.
- log_level
Loguru logging verbosity.
- Parameters:
- class lanspector.settings.DashboardPrepSettings(databases=<factory>, dashboard_db=PosixPath('landash.sqlite'), include_ntfs=True, include_acls=True, include_sunburst=True, log_level='INFO')[source]#
Bases:
objectPrepare or update the LANdash SQLite store from one or more crawl databases.
Run this subcommand before
lanspector dashboard. Explicitly list the crawl databases to ingest via--databases '[crawl1.db, crawl2.db]'.Example:
lanspector dashboard-prep --databases '[finance.db, hr.db]' --dashboard_db landash.sqlite lanspector dashboard --dashboard_db landash.sqlite
- Attributes:
- databases
One or more LANspector SQLite crawl database paths (e.g.
--databases a.dbor--databases '[a.db, b.db]').- dashboard_db
Destination SQLite database path for the LANdash web app (default
landash.sqlite).- include_ntfs
Extract parent-vs-child NTFS/POSIX permission timelines.
- include_acls
Extract ACL group membership records.
- include_sunburst
Extract directory storage & access-time records for sunburst exploration.
- log_level
Loguru logging verbosity.
- Parameters:
- class lanspector.settings.DashboardServeSettings(dashboard_db=PosixPath('landash.sqlite'), host='127.0.0.1', port=8050, debug=False, log_level='INFO')[source]#
Bases:
objectLaunch the interactive LANdash web dashboard (requires
lanspector[dashboard]).Before launching the dashboard, aggregate one or more crawl databases into a LANdash SQLite store using
lanspector dashboard-prep:Example:
lanspector dashboard-prep --databases '[finance.db]' --dashboard_db landash.sqlite lanspector dashboard --dashboard_db landash.sqlite --port 8050
- Attributes:
- dashboard_db
Path to the prepared LANdash SQLite database created by
lanspector dashboard-prep(defaultlandash.sqlite).- host
Interface address to bind the Dash server to.
- port
TCP port for the Dash server.
- debug
Run Dash in development debug mode.
- log_level
Loguru logging verbosity.
- Parameters:
- class lanspector.settings.GuiSettings(database=None, path=None, log_level='INFO')[source]#
Bases:
objectConfiguration for
lanspector gui.- Attributes:
- database
Optional initial crawl database path to pre-populate in the GUI.
- path
Optional initial directory path to pre-populate in the New Crawl tab.
- log_level
Loguru logging verbosity.
- Parameters:
- class lanspector.settings.ReportSettings(databases=<factory>, output=PosixPath('lanspector_report.xlsx'), table=None, limit=500, owner=None, subdir=None, per_user=False, use_permission_hierarchy=False, skip_files_report=False, skip_user_owner_report=False, report_pii=True, open_shares=False, log_level='INFO')[source]#
Bases:
objectConfiguration for
lanspector report.- Attributes:
- databases
One or more LANspector SQLite crawl database paths.
- output
Destination Excel workbook path (
.xlsx).- table
Crawl timestamp table name (defaults to latest crawl).
- limit
Maximum rows written to detail sheets (
Noneor0means unlimited).- owner
Optional owner filter to generate a single-owner report.
- subdir
Optional subdirectory filter.
- per_user
Generate separate per-owner Excel workbooks alongside the main workbook.
- use_permission_hierarchy
Collapse subordinate permissions (e.g.
MR->M,Fdominates all).- skip_files_report
Omit the
file_vs_folderACLsheet.- skip_user_owner_report
Omit the
Objects Owned by Usersheet.- report_pii
Include the
Possible PII Locationssheet.- open_shares
Generate an Open Shares summary workbook instead of a full fileshare audit report.
- log_level
Loguru logging verbosity.
- Parameters:
Bases:
objectConfiguration for
lanspector shares.- Attributes:
- servers
Fileserver hostnames or IPs to probe for SMB shares (Windows only).
- domains
Active Directory domain names to enumerate servers and shares (Windows only).
- test_connectivity
Filter servers by attempting a TCP connection to SMB port 445 first.
- get_share_permissions
Harvest share-level DACL permissions alongside share names.
- skip_admin_shares
Skip administrative shares ending in
$.- output
Optional CSV or Excel path to export discovered shares.
- log_level
Loguru logging verbosity.
- Parameters:
- class lanspector.settings.SunburstSettings(database, output=PosixPath('lanspector_sunburst.html'), table=None, subdir=None, limit=500, max_depth=None, color_by='age', include_plotlyjs='inline', open_browser=False, log_level='INFO')[source]#
Bases:
objectConfiguration for
lanspector sunburst.- Attributes:
- database
Path to a LANspector SQLite crawl database.
- output
Destination standalone HTML file path.
- table
Crawl timestamp table name (defaults to latest crawl).
- subdir
Optional subdirectory filter.
- limit
Maximum directories to include in the chart.
- max_depth
Optional maximum folder depth rendered in the sunburst rings.
- color_by
Color scale metric:
age(days since last access) orsize(bytes).- include_plotlyjs
inlineembeds Plotly.js for offline/air-gapped use;cdnkeeps the HTML small.- open_browser
Automatically open the generated HTML file in the system browser.
- log_level
Loguru logging verbosity.
- Parameters:
Typed data models and type aliases used across LANspector.
- class lanspector.datatypes.CrawlEntry(path, fname=None, bytes=0, owner=None, ctime=None, atime=None, mtime=None, md5=None, is_symlink=False, entry_id=None)[source]#
Bases:
objectMetadata harvested for a single directory or file entry.
- Attributes:
- path
Normalized directory path containing the object (or the directory itself).
- fname
Filename when the entry is a file, or
Nonefor directories.- bytes
Size in bytes (sum of contained files for directories when not skipped).
- owner
Account name owning the file or directory.
- ctime
Creation / metadata-change timestamp.
- atime
Last access timestamp.
- mtime
Last modification timestamp.
- md5
Optional MD5 hex digest.
- is_symlink
Whether the object is a symbolic link.
- entry_id
Assigned integer primary key during crawl persistence.
- Parameters:
- class lanspector.datatypes.CrawlResult(tablename, output_path=None, files_df=<factory>, perms_df=<factory>, pii_df=<factory>, objects_processed=0, report_path=None, sunburst_path=None)[source]#
Bases:
objectOutcome returned by
lanspector.crawler.crawl().- Attributes:
- tablename
Timestamp identifier of the crawl table (
YYYYMMDDTHHMMSS).- output_path
Destination file path if persisted to disk, otherwise
None.- files_df
In-memory metadata DataFrame when
foutisNone(empty otherwise).- perms_df
In-memory permissions DataFrame when
foutisNone(empty otherwise).- pii_df
In-memory PII findings DataFrame when
foutisNone(empty otherwise).- objects_processed
Total count of directories and files harvested during the crawl.
- report_path
Path to the generated Excel summary workbook if
summarize=True.- sunburst_path
Path to the generated standalone Plotly HTML sunburst chart if requested.
- Parameters:
- class lanspector.datatypes.ExecutiveSummary(info, acls_found=<factory>, owners_found=<factory>)[source]#
Bases:
objectHigh-level audit rollup returned by
lanspector.reader.CrawlReader.executive_summary().- Attributes:
- info
Crawl metadata and object counts/total size mapping.
- acls_found
Distinct ACL names discovered across the crawl.
- owners_found
Distinct file/folder owners discovered across the crawl.
- Parameters:
- class lanspector.datatypes.ParentChildResult(dirs_df, files_df)[source]#
Bases:
objectResult of the compressed parent-vs-child ACL difference report.
- Attributes:
- dirs_df
Folder permission-difference DataFrame (root + folders differing from parent), or
Nonewhen no directory permissions exist.- files_df
File-vs-folder elevated-permission DataFrame, or
Nonewhen skipped or empty.
- Parameters:
- class lanspector.datatypes.PermissionEntry(domain, name, permission, object_type, entry_id=None)[source]#
Bases:
objectSingle effective ACL/permission entry for a path or file.
- Attributes:
- domain
Domain or authority name (e.g. Windows domain,
BUILTIN, orPOSIX).- name
Account, group, or SID label.
- permission
Normalized permission string (e.g.
Read(RX),Change,Full Control(All)).- object_type
Principal category (
User,Group,WellKnownGroup,dead, etc.).- entry_id
Foreign key matching
CrawlEntry.entry_id.
- Parameters:
- class lanspector.datatypes.PiiFinding(pii_word_id, snippet, entry_id=None)[source]#
Bases:
objectSingle PII keyword or named-entity match within a crawled file.
- Attributes:
- pii_word_id
Index into
lanspector.constants.PII_KEYWORDS.- snippet
Contextual text snippet surrounding the match.
- entry_id
Foreign key matching
CrawlEntry.entry_id.
- Parameters:
Bases:
objectShare-level SMB permission entry harvested from a Windows fileserver.
- Attributes:
- server
Server hostname or IP.
- fqdn
Resolved fully qualified domain name.
- sharename
SMB share name.
- acl_domain
Domain of the share-level ACL principal.
- acl_name
Principal name granted share-level access.
- acl_type
Principal SID type label.
- permission
Share-level permission string.
- Parameters:
Immutable constants for LANspector crawling, permissions, PII detection, and reporting.