Add analyze mode and summary reporting to kInit #21
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/analyse"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
User description
analyze.shfor configuration verification and module result analysis.--analyzeoption tokInit.shto enable analysis mode.PR Type
Enhancement, Other
Description
Introduced
analyze.shto verify system, utilities, and software configurations.Added
--analyzeflag tokInit.shfor post-execution verification.Implemented
recordModuleResultto track and report module success/failure.Modified module cleanup logic to preserve variable files when analysis mode is active.
Diagram Walkthrough
File Walkthrough
7 files
New script for post-installation configuration verificationConditional cleanup of variable files based on analyze modePreserve software variables when analysis is enabledPrevent deletion of system variables in analyze modeSkip utilities variable cleanup during analysisAdded helper to record and track module execution resultsAdded --analyze CLI option and help documentation1 files
Updated checksums for modified shell scriptsPR Reviewer Guide 🔍
(Review updated until commit
e46f30afe0)Here are some key observations to aid the review process:
Arbitrary Code Execution:
The
analyze.shscript sources multiple.varsfiles (lines 32, 198, 242). Since these files are part of the installer's state, if an attacker can modify these files on the filesystem or intercept them during download, they can execute arbitrary bash commands with the privileges of the user runningkInit.sh(likely root). Consider using a safer parsing method likegreporawkto extract specific values instead of sourcing the entire file.Shell Injection
The script uses
sourceon.varsfiles (e.g.,system.vars,utilities.vars) which are likely generated or downloaded. If these files are compromised or contain untrusted input, it leads to arbitrary code execution.Logic Error
In
verifySystemConfig, the check forSWAP_SIZEuses-eqon a variable that might be an empty string or non-numeric if the.varsfile is malformed, which will cause a shell script error.Missing Validation
The
runAnalysisfunction accepts a string$1and usesgrepto check for success. If the input string is not formatted exactly as expected (e.g., extra spaces or different casing), the verification blocks for specific modules will be silently skipped.PR Code Suggestions ✨
Explore these optional code suggestions:
Prevent variable collisions by isolating module sourcing
The script sources multiple
.varsfiles into the same shell environment withoutnamespacing. This can lead to variable collisions where a later file overwrites
values from an earlier one, causing incorrect verification results. Consider using a
subshell or clearing specific variables between module checks.
installer/analyze.sh [21-128]
Suggestion importance[1-10]: 7
__
Why: The script sources multiple
.varsfiles into the global scope. Since these files likely share common variable names (likeTRUE,FALSE, or module-specific flags), sourcing them sequentially in the same shell can lead to unexpected behavior or false positives/negatives in verification.Check the correct user's shell during verification
The script hardcodes a check against the
rootuser in/etc/passwd. If the installerwas run for a non-root user, this verification will incorrectly report a failure
even if the current user's shell was successfully changed. Use the
$USERvariable orgetent passwd $(whoami)to check the shell of the user who actually performed theinstallation.
installer/analyze.sh [45-47]
Suggestion importance[1-10]: 5
__
Why: Hardcoding the check for the
rootuser's shell is restrictive. While many installers run as root, the verification should ideally target the user for whom the environment was configured, or at least use a more dynamic approach thangrep "^root:".Verify specific SSH keys instead of file existence
The check for SSH configuration only verifies the existence of the
authorized_keysfile but does not check if the keys defined in
SSH_KEY_DCSare actually presentinside that file. This can lead to false positives if the file exists but is empty
or contains unrelated keys. Use
grepto verify the presence of at least one expectedkey.
installer/analyze.sh [66-74]
Suggestion importance[1-10]: 6
__
Why: The current check only verifies that the
authorized_keysfile exists, which is a weak verification of whether the configuration was actually applied. Checking for the presence of the keys defined inSSH_KEY_DCSprovides a much more accurate result./review
Persistent review updated to latest commit
e46f30afe0WIP: Add analyze mode and summary reporting to kInitto Add analyze mode and summary reporting to kInit