Configuration Hardening 2
What changed:
- Added visible runtime override reporting with masking for sensitive values.
- Expanded effective config for build cleanup, script compiler discovery/env, extract layout/cleanup/
HAK discovery, wiki deploy defaults, autogen cache policy, and release-source env names.
- Wired configured values into build, script compiler resolution, extract, autogen cache refresh/max
age, parts manifest release source, wiki generation/deploy, and TLK output naming.
- Added config sources override output and validation-rule hints in config explain.
- Added CONFIGURATION_HARDENING_AUDIT.md.
- Updated README.md with config commands, schema defaults, and JSON artifact boundaries.
- Added regression tests for override visibility/masking, compiler/extract/wiki/autogen config,
configured HAK discovery, and config sources output.
This commit is contained in:
@@ -9,19 +9,21 @@ import (
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"gitea.westgate.pw/ShadowsOverWestgate/sow-tools/internal/project"
|
||||
)
|
||||
|
||||
func resolveScriptCompilerEnvironment() ([]string, error) {
|
||||
func resolveScriptCompilerEnvironment(p *project.Project) ([]string, error) {
|
||||
env := os.Environ()
|
||||
|
||||
userDir, err := resolveNWNUserDirectory()
|
||||
userDir, err := resolveNWNUserDirectory(p.ScriptCompilerNWNUserDirectoryEnvKeys())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
env = upsertEnv(env, "NWN_HOME", userDir)
|
||||
env = upsertEnv(env, "NWN_USER_DIRECTORY", userDir)
|
||||
|
||||
root, err := resolveNWNRoot()
|
||||
root, err := resolveNWNRoot(p.ScriptCompilerNWNRootEnvKeys())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -32,8 +34,8 @@ func resolveScriptCompilerEnvironment() ([]string, error) {
|
||||
return env, nil
|
||||
}
|
||||
|
||||
func resolveNWNUserDirectory() (string, error) {
|
||||
for _, key := range []string{"SOW_NWN_USER_DIRECTORY", "NWN_HOME", "NWN_USER_DIRECTORY"} {
|
||||
func resolveNWNUserDirectory(envKeys []string) (string, error) {
|
||||
for _, key := range envKeys {
|
||||
if value := strings.TrimSpace(os.Getenv(key)); value != "" {
|
||||
path := filepath.Clean(expandUserPath(value))
|
||||
if err := os.MkdirAll(path, 0o755); err != nil {
|
||||
@@ -71,8 +73,8 @@ func defaultNWNUserDirectory() (string, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func resolveNWNRoot() (string, error) {
|
||||
for _, key := range []string{"SOW_NWN_ROOT", "NWN_ROOT"} {
|
||||
func resolveNWNRoot(envKeys []string) (string, error) {
|
||||
for _, key := range envKeys {
|
||||
if value := strings.TrimSpace(os.Getenv(key)); value != "" {
|
||||
path := filepath.Clean(expandUserPath(value))
|
||||
if !looksLikeNWNInstall(path) {
|
||||
|
||||
Reference in New Issue
Block a user