-
Notifications
You must be signed in to change notification settings - Fork 1
refactor: capture time.Now() once at shell start, add NowSafe() guard, fix fuzz test context leaks #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: capture time.Now() once at shell start, add NowSafe() guard, fix fuzz test context leaks #117
Changes from all commits
aecc4cb
802c7b1
ac8dec6
cff9ed4
459e792
50c63b6
35e880d
71a07cc
0e74b7e
20370f9
61be3af
6aeb0d6
922025f
4528a28
0893caa
9937072
fe23d88
406aa85
aaa39b7
893151b
a6333ea
0871d05
e68b185
266061e
830017b
696f9e4
f432cef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -207,9 +207,7 @@ optLoop: | |
| } | ||
| } | ||
|
|
||
| // Capture invocation time once so -mtime/-mmin predicates use a | ||
| // consistent reference across all root paths (matches GNU find). | ||
| now := callCtx.Now() | ||
| now := callCtx.Now | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This read bypasses the new zero-value guard and silently treats an unset Useful? React with 👍 / 👎. |
||
|
|
||
| // GNU find treats a missing -newer reference as a fatal argument error | ||
| // and produces no result set, so skip the walk entirely. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -137,7 +137,7 @@ func registerFlags(fs *builtins.FlagSet) builtins.HandlerFunc { | |
| return builtins.Result{} | ||
| } | ||
|
|
||
| now := callCtx.Now() | ||
| now := callCtx.Now | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This line bypasses the new zero-value guard and reintroduces silent year-0001 behavior when Useful? React with 👍 / 👎. |
||
|
|
||
| // Determine the effective sort mode. When both -S and -t are given, | ||
| // the last one specified wins, matching GNU ls behaviour. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be removed, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Claude Sonnet 4.6] No — our PR makes
time.Nownecessary here.Runner.Run()now callstime.Now()directly to capturer.startTimebefore dispatching any builtin (interp/api.go:376). The entry was already present onmain(pre-existing since the find builtin PR), and our refactor legitimately uses it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we don't have anything statically stopping the implementations from just calling this themselves, which is the entire point. The sandbox itself shouldn't be subject to this allowlist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thieman hum, I don't understand the issue here, it's normal for /interp package to call
time.Now()once during the shell execution no? so listing it as allowed inallowedsymbols/symbols_interp.goseems to be normal.Maybe I'm not understanding your point here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Claude Sonnet 4.6] The entry is correct and needs to stay.
Runner.Run()ininterp/api.go:376callstime.Now()directly to capturer.startTimebefore dispatching any builtin. TheinterpAllowedSymbolslist enforces what symbols the interpreter core itself may use — it is a separate allowlist frombuiltinsAllowedSymbols, which is what restricts user-visible builtin code.time.Nowis intentionally absent fromsymbols_builtins.go, so builtins cannot call it directly; they must read the pre-capturedCallContext.Nowvalue instead. That separation is the actual enforcement mechanism.