implement ptero 1.12.3 security fix - #180
Conversation
implement security change from ptero 1.12.3 code cleanup
📝 WalkthroughWalkthroughConfiguration placeholder substitution in ChangesConfiguration Parsing Updates
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
parser/helpers.go (1)
207-223:⚠️ Potential issue | 🟠 Major | ⚡ Quick winStop silently swallowing config lookup errors caused by
errshadowing
Inparser/helpers.go(LookupConfigurationValue), the closure doesmatch, dataType, _, err := jsonparser.Get(...), which shadows the function’s named returnerr. On non-jsonparser.KeyPathNotFoundErrorfailures, the closure returnsplaceholderwithout assigning to the named return variable, so the caller doesn’t see the lookup error.💡 Suggested fix
result = configMatchRegex.ReplaceAllStringFunc(cfr.ReplaceWith.String(), func(placeholder string) string { if err != nil { return placeholder } keyPath := configMatchRegex.ReplaceAllString(placeholder, "$1") var path []string for _, part := range strings.Split(keyPath, ".") { path = append(path, strcase.ToSnake(part)) } // Look for the key in the Wings configuration and substitute the placeholder. - match, dataType, _, err := jsonparser.Get(f.configuration, path...) - if err != nil { - if err != jsonparser.KeyPathNotFoundError { + match, dataType, _, getErr := jsonparser.Get(f.configuration, path...) + if getErr != nil { + if getErr != jsonparser.KeyPathNotFoundError { + err = getErr return placeholder } log.WithFields(log.Fields{"path": path, "filename": f.FileName}).Debug("attempted to load a configuration value that does not exist") // Leave placeholder intact so the misconfiguration is visible. return placeholder }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@parser/helpers.go` around lines 207 - 223, The closure inside LookupConfigurationValue is shadowing the outer named return err by using := when calling jsonparser.Get, causing real lookup errors to be swallowed; change the variable binding so the call to jsonparser.Get assigns to the outer err (use = instead of := or assign to a new local errVar and set the outer err before returning) and ensure any non-jsonparser.KeyPathNotFoundError paths set the function's named err before returning the placeholder; update the closure around configMatchRegex.ReplaceAllStringFunc (the block using cfr.ReplaceWith.String(), keyPath, path, and jsonparser.Get) to fix the shadowing so callers receive the actual error.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@parser/helpers.go`:
- Around line 207-223: The closure inside LookupConfigurationValue is shadowing
the outer named return err by using := when calling jsonparser.Get, causing real
lookup errors to be swallowed; change the variable binding so the call to
jsonparser.Get assigns to the outer err (use = instead of := or assign to a new
local errVar and set the outer err before returning) and ensure any
non-jsonparser.KeyPathNotFoundError paths set the function's named err before
returning the placeholder; update the closure around
configMatchRegex.ReplaceAllStringFunc (the block using cfr.ReplaceWith.String(),
keyPath, path, and jsonparser.Get) to fix the shadowing so callers receive the
actual error.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ca042a16-088b-42fa-b04f-f17098b25ddc
📒 Files selected for processing (2)
parser/helpers.goparser/parser.go
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Build and Test (ubuntu-22.04, 1.26.0, linux, amd64)
- GitHub Check: Build and Test (ubuntu-22.04, 1.25.7, linux, amd64)
- GitHub Check: Analyze (go)
🔇 Additional comments (1)
parser/parser.go (1)
216-230: LGTM!Also applies to: 238-238
implement security change from ptero 1.12.3 code cleanup Co-authored-by: Michael (Parker) Parker <parkervcp@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Merge pelican-dev/wings main (commit a0306eb) into the fork. Brings in upstream PR pelican#180 (parser security fix). Replaces the fork's temporary hand-ported copy (old #6), so the canonical upstream commit is the source of that change with no duplicated content.
implement security change from ptero 1.12.3
code cleanup
Summary by CodeRabbit
Release Notes
Refactor
Bug Fixes