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: object

Crawl 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 --fout is omitted on the CLI, output defaults to ./<target>.db in 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 --driver is set).

fout

Output database or file path (.db, .sqlite, .sqlite3, .csv, .xlsx). Defaults to ./<target>.db in 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 driver is specified.

dryrun

When used with driver, discover targets without crawling them.

scantype

Objects to harvest: d (directories), f (files), or fd (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 (None disables).

skip_size

Skip aggregating file sizes inside directories when scantype='d'.

limit

Stop crawling after this many objects (0 means unlimited).

max_depth

Stop crawling after this many directory levels below path (0 means 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_end is NULL in CRAWL_INFO) in fout, skipping already-persisted directories and files.

n_procs

Maximum concurrent crawl worker processes in driver mode.

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'])

path: Path | None = None#
fout: Path | None = None#
driver: Path | None = None#
driver_out: Path | None = None#
dryrun: bool = False#
scantype: Literal['d', 'f', 'fd'] = 'fd'#
permissions: bool = True#
crawl_acls: bool = True#
max_md5: int | None = None#
skip_size: bool = False#
limit: int = 0#
max_depth: int = 0#
detect_pii: bool = False#
use_ner: bool = False#
summarize: bool = True#
sunburst_html: Path | None = None#
resume: bool = False#
n_procs: int | None = None#
log_level: Literal['ERROR', 'WARNING', 'INFO', 'DEBUG', 'TRACE'] = 'INFO'#
class lanspector.settings.CompareSettings(database, table_before=None, table_after=None, output=None, subdir=None, log_level='INFO')[source]#

Bases: object

Configuration 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:
  • database (Path)

  • table_before (str | None)

  • table_after (str | None)

  • output (Path | None)

  • subdir (str | None)

  • log_level (Literal['ERROR', 'WARNING', 'INFO', 'DEBUG', 'TRACE'])

database: Path#
table_before: str | None = None#
table_after: str | None = None#
output: Path | None = None#
subdir: str | None = None#
log_level: Literal['ERROR', 'WARNING', 'INFO', 'DEBUG', 'TRACE'] = 'INFO'#
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: object

Prepare 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.db or --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:
  • databases (Path | list[Path])

  • dashboard_db (Path)

  • include_ntfs (bool)

  • include_acls (bool)

  • include_sunburst (bool)

  • log_level (Literal['ERROR', 'WARNING', 'INFO', 'DEBUG', 'TRACE'])

databases: Path | list[Path]#
dashboard_db: Path = PosixPath('landash.sqlite')#
include_ntfs: bool = True#
include_acls: bool = True#
include_sunburst: bool = True#
log_level: Literal['ERROR', 'WARNING', 'INFO', 'DEBUG', 'TRACE'] = 'INFO'#
class lanspector.settings.DashboardServeSettings(dashboard_db=PosixPath('landash.sqlite'), host='127.0.0.1', port=8050, debug=False, log_level='INFO')[source]#

Bases: object

Launch 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 (default landash.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:
  • dashboard_db (Path)

  • host (str)

  • port (int)

  • debug (bool)

  • log_level (Literal['ERROR', 'WARNING', 'INFO', 'DEBUG', 'TRACE'])

dashboard_db: Path = PosixPath('landash.sqlite')#
host: str = '127.0.0.1'#
port: int = 8050#
debug: bool = False#
log_level: Literal['ERROR', 'WARNING', 'INFO', 'DEBUG', 'TRACE'] = 'INFO'#
class lanspector.settings.GuiSettings(database=None, path=None, log_level='INFO')[source]#

Bases: object

Configuration 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:
  • database (Path | None)

  • path (Path | None)

  • log_level (Literal['ERROR', 'WARNING', 'INFO', 'DEBUG', 'TRACE'])

database: Path | None = None#
path: Path | None = None#
log_level: Literal['ERROR', 'WARNING', 'INFO', 'DEBUG', 'TRACE'] = 'INFO'#
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: object

Configuration 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 (None or 0 means 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, F dominates all).

skip_files_report

Omit the file_vs_folderACL sheet.

skip_user_owner_report

Omit the Objects Owned by User sheet.

report_pii

Include the Possible PII Locations sheet.

open_shares

Generate an Open Shares summary workbook instead of a full fileshare audit report.

log_level

Loguru logging verbosity.

Parameters:
  • databases (Path | list[Path])

  • output (Path)

  • table (str | None)

  • limit (int | None)

  • owner (str | None)

  • subdir (str | None)

  • per_user (bool)

  • use_permission_hierarchy (bool)

  • skip_files_report (bool)

  • skip_user_owner_report (bool)

  • report_pii (bool)

  • open_shares (bool)

  • log_level (Literal['ERROR', 'WARNING', 'INFO', 'DEBUG', 'TRACE'])

databases: Path | list[Path]#
output: Path = PosixPath('lanspector_report.xlsx')#
table: str | None = None#
limit: int | None = 500#
owner: str | None = None#
subdir: str | None = None#
per_user: bool = False#
use_permission_hierarchy: bool = False#
skip_files_report: bool = False#
skip_user_owner_report: bool = False#
report_pii: bool = True#
open_shares: bool = False#
log_level: Literal['ERROR', 'WARNING', 'INFO', 'DEBUG', 'TRACE'] = 'INFO'#
class lanspector.settings.SharesListSettings(servers=<factory>, domains=<factory>, test_connectivity=False, get_share_permissions=True, skip_admin_shares=True, output=None, log_level='INFO')[source]#

Bases: object

Configuration 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:
  • servers (str | list[str])

  • domains (str | list[str])

  • test_connectivity (bool)

  • get_share_permissions (bool)

  • skip_admin_shares (bool)

  • output (Path | None)

  • log_level (Literal['ERROR', 'WARNING', 'INFO', 'DEBUG', 'TRACE'])

servers: str | list[str]#
domains: str | list[str]#
test_connectivity: bool = False#
get_share_permissions: bool = True#
skip_admin_shares: bool = True#
output: Path | None = None#
log_level: Literal['ERROR', 'WARNING', 'INFO', 'DEBUG', 'TRACE'] = 'INFO'#
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: object

Configuration 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) or size (bytes).

include_plotlyjs

inline embeds Plotly.js for offline/air-gapped use; cdn keeps the HTML small.

open_browser

Automatically open the generated HTML file in the system browser.

log_level

Loguru logging verbosity.

Parameters:
  • database (Path)

  • output (Path)

  • table (str | None)

  • subdir (str | None)

  • limit (int | None)

  • max_depth (int | None)

  • color_by (Literal['age', 'size'])

  • include_plotlyjs (Literal['cdn', 'inline'])

  • open_browser (bool)

  • log_level (Literal['ERROR', 'WARNING', 'INFO', 'DEBUG', 'TRACE'])

database: Path#
output: Path = PosixPath('lanspector_sunburst.html')#
table: str | None = None#
subdir: str | None = None#
limit: int | None = 500#
max_depth: int | None = None#
color_by: Literal['age', 'size'] = 'age'#
include_plotlyjs: Literal['cdn', 'inline'] = 'inline'#
open_browser: bool = False#
log_level: Literal['ERROR', 'WARNING', 'INFO', 'DEBUG', 'TRACE'] = 'INFO'#

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: object

Metadata 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 None for 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:
path: str#
fname: str | None#
bytes: int#
owner: str | None#
ctime: datetime | None#
atime: datetime | None#
mtime: datetime | None#
md5: str | None#
entry_id: int | None#
to_record()[source]#

Convert this entry into a flat SQLite/DataFrame record dictionary.

Return type:

dict[str, Any]

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: object

Outcome 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 fout is None (empty otherwise).

perms_df

In-memory permissions DataFrame when fout is None (empty otherwise).

pii_df

In-memory PII findings DataFrame when fout is None (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:
tablename: str#
output_path: Path | None#
files_df: DataFrame#
perms_df: DataFrame#
pii_df: DataFrame#
objects_processed: int#
report_path: Path | None#
sunburst_path: Path | None#
class lanspector.datatypes.ExecutiveSummary(info, acls_found=<factory>, owners_found=<factory>)[source]#

Bases: object

High-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:
info: dict[str, Any]#
acls_found: list[str]#
owners_found: list[str]#
class lanspector.datatypes.ParentChildResult(dirs_df, files_df)[source]#

Bases: object

Result of the compressed parent-vs-child ACL difference report.

Attributes:
dirs_df

Folder permission-difference DataFrame (root + folders differing from parent), or None when no directory permissions exist.

files_df

File-vs-folder elevated-permission DataFrame, or None when skipped or empty.

Parameters:
dirs_df: DataFrame | None#
files_df: DataFrame | None#
class lanspector.datatypes.PermissionEntry(domain, name, permission, object_type, entry_id=None)[source]#

Bases: object

Single effective ACL/permission entry for a path or file.

Attributes:
domain

Domain or authority name (e.g. Windows domain, BUILTIN, or POSIX).

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:
  • domain (str)

  • name (str)

  • permission (str)

  • object_type (str)

  • entry_id (int | None)

domain: str#
name: str#
permission: str#
object_type: str#
entry_id: int | None#
to_record()[source]#

Convert this permission entry into a SQLite/DataFrame record dictionary.

Return type:

dict[str, Any]

class lanspector.datatypes.PiiFinding(pii_word_id, snippet, entry_id=None)[source]#

Bases: object

Single 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:
  • pii_word_id (int)

  • snippet (str)

  • entry_id (int | None)

pii_word_id: int#
snippet: str#
entry_id: int | None#
to_record()[source]#

Convert this finding into a SQLite/DataFrame record dictionary.

Return type:

dict[str, Any]

class lanspector.datatypes.SharePermissionEntry(server, fqdn, sharename, acl_domain, acl_name, acl_type, permission)[source]#

Bases: object

Share-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:
  • server (str)

  • fqdn (str)

  • sharename (str)

  • acl_domain (str)

  • acl_name (str)

  • acl_type (str)

  • permission (str)

server: str#
fqdn: str#
sharename: str#
acl_domain: str#
acl_name: str#
acl_type: str#
permission: str#
to_record()[source]#

Convert this share permission into a SQLite/DataFrame record dictionary.

Return type:

dict[str, Any]

Immutable constants for LANspector crawling, permissions, PII detection, and reporting.