Skip to content

Commit

Permalink
provide our own policy
Browse files Browse the repository at this point in the history
  • Loading branch information
NilsIrl committed Mar 6, 2024
1 parent ea297f3 commit 5f4092a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/dockerc.zig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const io = std.io;
const skopeo_content = @embedFile("tools/skopeo");
const mksquashfs_content = @embedFile("tools/mksquashfs");
const umoci_content = @embedFile("tools/umoci.amd64");

const policy_content = @embedFile("tools/policy.json");

const runtime_content = @embedFile("runtime");

const runtime_content_len_u64 = data: {
Expand All @@ -37,6 +40,9 @@ pub fn main() !void {
const mksquashfs_path = try extract_file(temp_dir_path, "mksquashfs", mksquashfs_content, allocator);
defer allocator.free(mksquashfs_path);

const policy_path = try extract_file(temp_dir_path, "policy.json", policy_content, allocator);
defer allocator.free(policy_path);

const params = comptime clap.parseParamsComptime(
\\-h, --help Display this help and exit.
\\-i, --image <str> Image to pull.
Expand Down Expand Up @@ -84,7 +90,7 @@ pub fn main() !void {
const destination_arg = try std.fmt.allocPrint(allocator, "oci:{s}/image:latest", .{temp_dir_path});
defer allocator.free(destination_arg);

var skopeoProcess = std.ChildProcess.init(&[_][]const u8{ skopeo_path, "copy", image, destination_arg }, gpa.allocator());
var skopeoProcess = std.ChildProcess.init(&[_][]const u8{ skopeo_path, "copy", "--policy", policy_path, image, destination_arg }, gpa.allocator());
_ = try skopeoProcess.spawnAndWait();

const umoci_image_layout_path = try std.fmt.allocPrint(allocator, "{s}/image:latest", .{temp_dir_path});
Expand Down
7 changes: 7 additions & 0 deletions src/tools/policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"default": [
{
"type": "insecureAcceptAnything"
}
]
}

0 comments on commit 5f4092a

Please sign in to comment.