Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions src/cli/audit_command.zig
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ fn buildProductionPackageSet(allocator: std.mem.Allocator, pm: *PackageManager,
const resolutions = pm.lockfile.buffers.resolutions.items;
const root_id = pm.root_package_id.get(pm.lockfile, pm.workspace_name_hash);

var queue = std.ArrayList(u32).init(allocator);
var queue = std.fifo.LinearFifo(u32, .Dynamic).init(allocator);
defer queue.deinit();

const root_deps = pkg_dependencies[root_id];
Expand All @@ -207,19 +207,14 @@ fn buildProductionPackageSet(allocator: std.mem.Allocator, pm: *PackageManager,
const res_slice = root_resolutions.get(resolutions);

for (dep_slice, res_slice) |dep, resolved_pkg_id| {
if (!dep.behavior.isDev()) {
if (resolved_pkg_id < pkg_names.len) {
const pkg_name = pkg_names[resolved_pkg_id].slice(buf);
try prod_set.put(pkg_name, {});
try queue.append(resolved_pkg_id);
}
if (!dep.behavior.isDev() and resolved_pkg_id < packages.len) {
const pkg_name = pkg_names[resolved_pkg_id].slice(buf);
try prod_set.put(pkg_name, {});
try queue.writeItem(resolved_pkg_id);
}
}

while (queue.items.len > 0) {
const current_pkg_id = queue.orderedRemove(0);
if (current_pkg_id >= pkg_names.len) continue;

while (queue.readItem()) |current_pkg_id| {
const current_deps = pkg_dependencies[current_pkg_id];
const current_resolutions = pkg_resolutions[current_pkg_id];
const current_dep_slice = current_deps.get(dependencies);
Expand All @@ -231,7 +226,7 @@ fn buildProductionPackageSet(allocator: std.mem.Allocator, pm: *PackageManager,
const pkg_name = pkg_names[resolved_pkg_id].slice(buf);
if (!prod_set.contains(pkg_name)) {
try prod_set.put(pkg_name, {});
try queue.append(resolved_pkg_id);
try queue.writeItem(resolved_pkg_id);
}
}
}
Expand Down
13 changes: 8 additions & 5 deletions src/install/PackageManager/CommandLineArguments.zig
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,15 @@ pub const AuditLevel = enum {
high,
critical,

const Map = bun.ComptimeStringMap(AuditLevel, .{
.{ "low", .low },
.{ "moderate", .moderate },
.{ "high", .high },
.{ "critical", .critical },
});

pub fn fromString(str: []const u8) ?AuditLevel {
if (bun.strings.eqlComptime(str, "low")) return .low;
if (bun.strings.eqlComptime(str, "moderate")) return .moderate;
if (bun.strings.eqlComptime(str, "high")) return .high;
if (bun.strings.eqlComptime(str, "critical")) return .critical;
return null;
return Map.get(str);
}

pub fn shouldIncludeSeverity(self: AuditLevel, severity: []const u8) bool {
Expand Down