fix: address PR #63 review findings

1. Refactor err2 to use scoped loadErr variable (MINOR - sonnet-review-bot)
   The else-if branches are mutually exclusive, so the error variable
   should be scoped inside the block, not declared outside with err2.

2. Sanitize DisplayName before embedding in Markdown (MINOR - security-review-bot)
   Remote persona metadata is untrusted. Added sanitizeMarkdownText() to
   escape Markdown special characters and strip control characters.
   Applied to both the header title and the footer attribution.

3. Document YAML DoS mitigations (MINOR - security-review-bot)
   Added comprehensive comment in remote_persona.go explaining existing
   defenses: file size limit, file count cap, depth limit, node count cap,
   and alias cycle detection. These collectively mitigate billion-laughs
   and stack exhaustion attacks.
This commit is contained in:
Rodin
2026-05-10 20:54:20 -07:00
parent 5fac8bc505
commit 27a9be38bc
4 changed files with 106 additions and 9 deletions
+4 -4
View File
@@ -205,12 +205,12 @@ func main() {
slog.Error("invalid persona-file path", "error", err)
os.Exit(1)
}
var err2 error
persona, err2 = review.LoadPersona(resolvedPath)
if err2 != nil {
slog.Error("failed to load persona file", "file", *personaFile, "error", err2)
loadedPersona, loadErr := review.LoadPersona(resolvedPath)
if loadErr != nil {
slog.Error("failed to load persona file", "file", *personaFile, "error", loadErr)
os.Exit(1)
}
persona = loadedPersona
slog.Info("loaded persona from file", "file", *personaFile, "persona", persona.Name)
}