Rename application to Samsara and add assessment summary, detailed tabs and local Linux inventory
This commit is contained in:
@@ -1,29 +1,37 @@
|
||||
# Development guide
|
||||
# Developer guide
|
||||
|
||||
Run commands from the repository root. Use a Python 3.11+ virtual environment and requirements.txt. Start with `python -m server_buddy.main`. Assets are resolved relative to the module, independent of the user's working directory; tests use repository-relative schema/fixture paths.
|
||||
Use Python 3.11+ and requirements.txt. Run `python -m samsara.main` from the repository root. The desktop requires a Qt-capable graphical session; tests run offscreen.
|
||||
|
||||
## Phase 1 behavior
|
||||
## UI and orchestration
|
||||
|
||||
Qt widgets stay on the GUI thread. CollectionJob loads the bundled JSON in a QThread and delivers stage/result/error signals. Analyze and import buttons are disabled until the worker finishes; closing an active job is deferred to avoid destroying a running thread. Demo loading is finite local I/O; production timeout/cancellation and process lifecycle management are Phase 3 requirements. No subprocesses are launched in Phase 1.
|
||||
Analyze is the default page. Source and OS selection are visible together; Auto-detect is the default. The OS selector is disabled for saved inventories and fixed synthetic samples because their OS is recorded in the input. Windows and RHEL version profiles are explicit user intent, not promises of live collector availability.
|
||||
|
||||
Tables use Qt proxy filtering across all columns with native numeric sorting. Session history records repeated fixture loads without changing fixture timestamps. Dashboard counts unique hostnames from fixture/import history, while history counts runs. High-risk findings refer to the current assessment. Two OS-specific fixtures supply the demo; user input cannot relabel synthetic evidence as a live server assessment.
|
||||
`CollectionJob` runs detection and collection outside the GUI thread, then delivers stage, result or failure signals. OS mismatches and unsupported collectors preserve the previous result. Cancellation uses QThread interruption and the Linux runner's polling callback. All source/profile controls are locked while collecting. Closing an active worker is deferred to avoid destroying a running thread.
|
||||
|
||||
Risk rules live in analyzers/assessment.py. Each finding contains classification, evidence, severity and points. Score is the sum capped at 100: 0 informational, 1–29 low, 30–59 medium, 60–89 high, 90–100 critical. These preliminary rules are demonstration logic, not a validated production risk model. Severity is an individual finding's severity, while overall risk is the aggregate. Observation limits always contribute uncertainty.
|
||||
Results are initially empty. Successful assessments create session history records; choosing one restores its inventory and derived assessment. Reports always use the displayed assessment. Successful analysis opens the dedicated Summary page. Its first tab shows retirement risk, OS/version, a capped list of workload software hints and enabled scheduled work. Comprehensive tabs lazily load searchable inventory and evidence tables. The same compact summary is included in HTML reports; all inventory remains exported. Scrollable pages and fixed-size form cards preserve legibility at smaller window sizes.
|
||||
|
||||
Collection JSON uses schemas/inventory-v1.schema.json. Export JSON wraps the collection as inventory_result and includes the derived assessment. Do not treat the report wrapper as collection JSON. Live collection must enforce the schema at the boundary and tighten field schemas as PowerShell contracts are implemented. Never replace failed checks with synthetic values.
|
||||
## OS detection
|
||||
|
||||
## Verification in this development environment
|
||||
`core/detection.py` reads local platform metadata and `/etc/os-release`, recognizes RHEL-related families and validates explicit major-version profiles. It does not resolve names or contact remote systems. Other Linux distributions may use Auto-detect. Windows desktop build numbers are not treated as Windows Server edition evidence. Saved inventories use their metadata and skip local OS detection.
|
||||
|
||||
Python 3.12.3 is available. `python3 -m unittest discover -s tests -v`: four tests passed; schema and Qt smoke tests skipped because jsonschema and PySide6 are absent. An isolated installation under /tmp failed due to package server DNS/network resolution. GUI launch and visual appearance have not been verified here. Run the documented tests after installing dependencies on Linux Mint; also test a Windows desktop before distribution.
|
||||
## Linux backend
|
||||
|
||||
No PowerShell collection scripts or production collector exist yet, so there is no real PowerShell output to validate. Phase 1 requires no remote accounts, remoting configuration, or administrative privilege.
|
||||
`collectors/linux.py` executes fixed arguments from system binary directories with a restricted environment, no shell or user hostname, suppressed command diagnostics and no sudo. Commands are polled for cancellation, an eight-second limit and 10 MiB output bound, then killed/reaped on failure. Overall command collection is limited to approximately 60 seconds. Reads are limited to local OS/proc metadata; remote mounts are not traversed. The headless CLI uses only the standard library and creates new output files exclusively.
|
||||
|
||||
## Follow-up verification
|
||||
Report source is included in locally collected server metadata. Import removes that field and treats source assertions as unverified. Inventory import validates schemas/inventory-v1.schema.json, caps size, strips diagnostic strings and command fields, and recalculates assessment results. Tighten field definitions alongside future production collector contracts.
|
||||
|
||||
After dependencies were installed in the project virtual environment: `.venv/bin/python -m unittest discover -s tests -v` passed all 12 tests, including two offscreen Qt tests, schema validation, Linux inventory import/NFS evidence, sensitive-field exclusion and startup diagnostics. Source compilation passed. Normal X11 startup is blocked by the confirmed missing `libxcb-cursor.so.0`; the launcher prints Mint installation instructions. Windows execution and real RHEL collection remain untested/unimplemented as described in PLATFORMS.md.
|
||||
## Analysis
|
||||
|
||||
## Local Linux collector
|
||||
Each finding has classification, supporting evidence, severity and points. Score is capped at 100: 0 informational, 1–29 low, 30–59 medium, 60–89 high, 90–100 critical. This is demonstration heuristic logic, not a validated production risk model. Known Linux application service names receive potential-dependency findings; other running services remain unknown rather than all being classified as application workloads. Incomplete checks and observation limits always require review.
|
||||
|
||||
`collectors/linux.py` executes fixed argument lists from system binary directories with a restricted environment, no shell or user hostname, DEVNULL stderr and no sudo. Each process is polled for cancellation, an eight-second time limit and a 10 MiB output limit; the process is killed and reaped on interruption/failure. Overall collection is bounded to approximately 60 seconds for command execution. Local /proc and /etc/os-release reads do not access mounted remote filesystems. There is no arbitrary command UI. Collection source is included in server metadata; JSON import strips that source field and treats imported evidence as unverified. GUI workers retain the previous assessment on cancellation. New local checks intentionally return partial/missing statuses rather than asserting full coverage.
|
||||
## Verification
|
||||
|
||||
Verification: 21 unit/UI tests passed, plus a real local read-only smoke collection validated against the JSON schema with HTML/JSON generation. Tests use both RPM and dpkg fixtures, check service/IPv6 parsing and unknown-service classification, command timeout/reaping, cancellation, and source labels. Real RHEL and Windows execution is still pending.
|
||||
Run `python -m unittest discover -s tests -v`. Coverage includes profiles/detection, synthetic isolation, real-source labels, RPM/dpkg parsing, IPv4/IPv6, missing commands, cancellation/timeouts, no automatic assessments, history restoration, imports, UI selection and HTML escaping/export. Offscreen snapshots can verify geometry at standard and smaller resolutions; they do not replace native desktop testing.
|
||||
|
||||
A local Linux smoke collection has passed schema validation and HTML/JSON generation in the restricted development environment. Systemd/interface restrictions were recorded as failed checks. Real Windows and RHEL release validation, remote transports and packaging are still pending. Never replace missing checks with samples.
|
||||
|
||||
Summary presentation is derived by analyzers/summary.py without altering assessment scores. Higher numbers mean more retirement concerns. OS version uses explicit os_version or an OS-name version hint, never the kernel/build as a fallback. Software name rules omit obvious library/development/documentation packages; a running service without a matching package can still be highlighted. Unknown schedules and missing checks remain explicit. Linux scheduler metadata includes system timer calendars/next-run data and bounded readable /etc/crontab and /etc/cron.d entries. Cron command arguments, inline code and environment assignments never enter the collected data; safe script/executable names identify work. User crontabs, anacron, periodic-script contents and execution history remain outside coverage.
|
||||
|
||||
## Application branding
|
||||
|
||||
The supplied Samsara JPEG is bundled unchanged as `samsara/assets/samsara-logo.jpg`. `ui/branding.py` provides the shared Qt application/window icon and Windows taskbar application identity. The sidebar uses the same asset. Future packaged builds must include this asset; the original `App Logo` folder is not required at runtime. Icon loading was checked at 16–256 pixel sizes and the sidebar preview was reviewed offscreen. Native desktop/taskbar appearance still needs platform verification.
|
||||
|
||||
Reference in New Issue
Block a user