Repository navigation
feat: kosli get rego-policy --download writes a version's bundle to a file - #1290
Conversation
…directory The server now serves every file of a rego policy version as one gzipped tar (kosli-dev/server#7380). --download DIR, with --policy-version, writes those files into DIR at the paths they were published with, so a version can be inspected or replayed offline. Every member is checked before any file is written: it must be a regular file at a path inside DIR, and no file may already exist there. A refused bundle leaves the directory as it was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Claude finished @jumboduck's task in 3m 6s —— View job Follow-up review of the newest commits (
|
Review of #1290 found ways past the promise that a refused bundle writes nothing. A path held twice was written twice, and a path held both as a file and as a directory failed after part of the bundle was written. Both are refused now, before any write. The server does not refuse the second case at publish, so a real bundle can hold it. Writes go through os.Root with O_EXCL, so a symlink already inside the directory cannot lead a write out of it. A bundle over 8 MiB decompressed is refused, and directory entries are accepted. A test pins the refusal of an empty --download, which the root command already gives. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ry left by a failed write Review of #1290. The decompression cap is a 100 MiB safety bound, no longer tied to the server's upload rule. Entry names go through utils.LocalRelativePath, so a leading "/" is trimmed and ".. " or "..." segments are refused as in the Azure unzip. The already-exists error says how to recover. A directory the command created is removed when a write fails; one that existed before is kept. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…a file Review of #1290. The bundle is written as the server sends it, a gzipped tar, with no extraction. This drops internal/regopolicies/bundle.go and its path-safety, size-cap and cleanup code. An existing file is refused and kept. Extraction into a directory can follow as its own slice if users ask for it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Follow-up review of the new commits (
|
Review of #1290. A partial file left by a write or close error made a retry fail as "already exists". The file is now removed on either error, so a retry starts clean. No test: a portable test cannot force a write failure on a real file. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… file Review of #1290. The bundle is written as the server sends it, a gzipped tar, with no extraction. This drops internal/regopolicies/bundle.go and its path-safety, size-cap and cleanup code. An existing file is refused and kept. Extraction into a directory can follow as its own slice if users ask for it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Review of #1290. A partial file left by a write or close error made a retry fail as "already exists". The file is now removed on either error, so a retry starts clean. No test: a portable test cannot force a write failure on a real file. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
0fcec9e to
2333f99
Compare
kosli get rego-policygets a--download FILEflag. With--policy-version, it writes the bundle of that version toFILEas a gzipped tar, exactly as the server sends it. It uses the bundle route that kosli-dev/server#7590 added. Part of kosli-dev/server#7380.Behaviour
Downloaded version 3 of rego policy 'pr-approved' to ./pr-approved-v3.tgz, in place of the version table.--downloadwithout--policy-versionis refused before any request. An empty--downloadis refused too.FILEis refused and kept. The error says to remove it or choose another file.tar -xzffirst.Tests
BundleURL.--policy-version, the empty value, and the 404.download.make lint: 0 issues. Not yet run end to end against a server with the bundle route.Checklist
charts/k8s-reporter/) updated, if needed. Note: these changes live in a separate PR🤖 Generated with Claude Code