mirror of
https://github.com/openai/codex.git
synced 2026-04-24 22:54:54 +00:00
fix: clippy
This commit is contained in:
@@ -255,13 +255,12 @@ pub fn log_admin_event(config: &AdminAuditConfig, payload: AdminAuditPayload) {
|
||||
return;
|
||||
}
|
||||
|
||||
let record = AdminAuditRecord::new(payload.clone());
|
||||
let record = AdminAuditRecord::new(payload);
|
||||
|
||||
if let Some(path) = &config.log_file {
|
||||
if let Err(err) = append_record_to_file(path, &record) {
|
||||
if let Some(path) = &config.log_file
|
||||
&& let Err(err) = append_record_to_file(path, &record) {
|
||||
warn!(path = %path.display(), ?err, "failed to write admin audit event");
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(endpoint) = &config.log_endpoint {
|
||||
send_record_to_endpoint(endpoint, record);
|
||||
@@ -275,7 +274,7 @@ fn append_record_to_file(path: &Path, record: &AdminAuditRecord) -> io::Result<(
|
||||
|
||||
let mut file = OpenOptions::new().create(true).append(true).open(path)?;
|
||||
let line =
|
||||
serde_json::to_string(record).map_err(|err| io::Error::new(io::ErrorKind::Other, err))?;
|
||||
serde_json::to_string(record).map_err(io::Error::other)?;
|
||||
file.write_all(line.as_bytes())?;
|
||||
file.write_all(b"\n")?;
|
||||
Ok(())
|
||||
|
||||
@@ -229,8 +229,8 @@ impl Executor {
|
||||
config: &ExecutorConfig,
|
||||
stdout_stream: Option<StdoutStream>,
|
||||
) -> Result<ExecToolCallOutput, CodexErr> {
|
||||
if let Some(admin_audit) = config.admin_audit.as_ref() {
|
||||
if admin_audit.should_log(AdminAuditEventKind::Command) {
|
||||
if let Some(admin_audit) = config.admin_audit.as_ref()
|
||||
&& admin_audit.should_log(AdminAuditEventKind::Command) {
|
||||
let payload = build_command_audit_payload(
|
||||
¶ms,
|
||||
sandbox,
|
||||
@@ -239,7 +239,6 @@ impl Executor {
|
||||
);
|
||||
log_admin_event(admin_audit, payload);
|
||||
}
|
||||
}
|
||||
process_exec_tool_call(
|
||||
params,
|
||||
sandbox,
|
||||
|
||||
@@ -199,8 +199,8 @@ pub async fn run_main(cli: Cli, codex_linux_sandbox_exe: Option<PathBuf>) -> any
|
||||
let config = Config::load_with_cli_overrides(cli_kv_overrides, overrides).await?;
|
||||
|
||||
if config.admin.has_pending_danger() {
|
||||
if let Some(audit) = config.admin.audit.as_ref() {
|
||||
if let Some(pending) = config.admin.pending.iter().find_map(|action| match action {
|
||||
if let Some(audit) = config.admin.audit.as_ref()
|
||||
&& let Some(pending) = config.admin.pending.iter().find_map(|action| match action {
|
||||
PendingAdminAction::Danger(pending) => Some(pending),
|
||||
}) {
|
||||
log_admin_event(
|
||||
@@ -208,7 +208,6 @@ pub async fn run_main(cli: Cli, codex_linux_sandbox_exe: Option<PathBuf>) -> any
|
||||
build_danger_audit_payload(pending, DangerAuditAction::Denied, None),
|
||||
);
|
||||
}
|
||||
}
|
||||
bail!(
|
||||
"danger-full-access requires interactive justification; rerun in the interactive TUI"
|
||||
);
|
||||
|
||||
@@ -431,7 +431,7 @@ impl App {
|
||||
|
||||
fn handle_apply_approval_preset(&mut self, preset: ApprovalPreset) -> Result<()> {
|
||||
let approval = preset.approval;
|
||||
let sandbox = preset.sandbox.clone();
|
||||
let sandbox = preset.sandbox;
|
||||
|
||||
match sandbox.clone() {
|
||||
SandboxPolicy::DangerFullAccess => match self.config.admin.decision_for_danger() {
|
||||
@@ -543,14 +543,13 @@ impl App {
|
||||
let pending_widget = self.chat_widget.take_pending_danger();
|
||||
let _ = self.chat_widget.config_mut().admin.take_pending_danger();
|
||||
|
||||
if let Some(pending) = pending_config.or(pending_widget) {
|
||||
if let Some(audit) = self.config.admin.audit.as_ref() {
|
||||
if let Some(pending) = pending_config.or(pending_widget)
|
||||
&& let Some(audit) = self.config.admin.audit.as_ref() {
|
||||
log_admin_event(
|
||||
audit,
|
||||
build_danger_audit_payload(&pending, DangerAuditAction::Cancelled, None),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let approval_label = self.config.approval_policy.to_string();
|
||||
let sandbox_label = Self::sandbox_policy_label(&self.config.sandbox_policy);
|
||||
|
||||
Reference in New Issue
Block a user