fix(webui): mark cookies Secure behind a TLS proxy; run gosec in the gate (#1919)
Cookies took Secure from r.TLS, which is nil behind a proxy that terminates TLS, so sign-in cookies went out without it. Every dashboard cookie now goes through one builder that reads the scheme the way the origin check does. The worktree reset and the agent worker's chown walk use os.Root, so a symlink swapped in mid-walk can't point them outside the worktree. gosec runs in golangci-lint, tests included. G104, G115, G204 and G304 are excluded in config; each remaining finding is fixed or suppressed at the site with its reason.
This commit is contained in:
46 files changed
+199
-115
No files matched your search
@@ -111,13 +111,19 @@ func (h *hybridTrees) HasUncommittedChanges(ctx context.Context, dir string) (bo
|
||||
|
||||
var _ workflow.Trees = (*hybridTrees)(nil)
|
||||
|
||||
// chownTree recursively lchowns dir to uid:gid.
|
||||
// chownTree recursively lchowns dir to uid:gid, through a root so a symlink
|
||||
// swapped in mid-walk cannot point it outside dir.
|
||||
func chownTree(dir string, uid, gid int) error {
|
||||
return filepath.WalkDir(dir, func(path string, _ fs.DirEntry, err error) error {
|
||||
root, err := os.OpenRoot(dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() { _ = root.Close() }()
|
||||
return fs.WalkDir(root.FS(), ".", func(path string, _ fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.Lchown(path, uid, gid)
|
||||
return root.Lchown(path, uid, gid)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user