Address code review feedback and security fixes

Co-authored-by: blackboxprogramming <118287761+blackboxprogramming@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-24 23:20:10 +00:00
parent 9e4fe64ad3
commit b7c153886f
3 changed files with 11 additions and 7 deletions

View File

@@ -35,6 +35,9 @@ on:
required: false required: false
default: "" default: ""
permissions:
contents: read
jobs: jobs:
spawn-runner: spawn-runner:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@@ -52,8 +52,8 @@ function parseSpawnRules(content) {
continue; continue;
} }
// Parse key-value pairs // Parse key-value pairs (supports alphanumeric, underscore, and hyphen in keys)
const kvMatch = trimmed.match(/^(\w+):\s*(.*)$/); const kvMatch = trimmed.match(/^([\w-]+):\s*(.*)$/);
if (kvMatch) { if (kvMatch) {
const key = kvMatch[1]; const key = kvMatch[1];
let value = kvMatch[2]; let value = kvMatch[2];
@@ -102,7 +102,7 @@ function evaluateCondition(condition, value) {
const isPct = condition.includes("%"); const isPct = condition.includes("%");
const condStr = condition.replace("%", "").trim(); const condStr = condition.replace("%", "").trim();
const match = condStr.match(/^([><=!]+)\s*(\d+(?:\.\d+)?)$/); const match = condStr.match(/^(>=|<=|!=|==|>|<|=)\s*(\d+(?:\.\d+)?)$/);
if (!match) return false; if (!match) return false;
const operator = match[1]; const operator = match[1];

View File

@@ -1,6 +1,7 @@
import { describe, expect, it, vi, beforeEach, afterEach } from "vitest"; import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";
import path from "path"; import path from "path";
import fs from "fs"; import fs from "fs";
import os from "os";
// Import the module functions // Import the module functions
const spawnRunner = require("../bot/lucidia-spawn-runner.js"); const spawnRunner = require("../bot/lucidia-spawn-runner.js");
@@ -287,8 +288,8 @@ spawn_rules:
it("spawns agents when conditions are met", () => { it("spawns agents when conditions are met", () => {
const consoleSpy = vi.spyOn(console, "log").mockImplementation(() => {}); const consoleSpy = vi.spyOn(console, "log").mockImplementation(() => {});
// Create a temp file with test spawn rules // Create a temp file with test spawn rules using cross-platform temp directory
const tempPath = "/tmp/test-spawn-rules.yml"; const tempPath = path.join(os.tmpdir(), "test-spawn-rules.yml");
fs.writeFileSync(tempPath, ` fs.writeFileSync(tempPath, `
spawn_rules: spawn_rules:
- if: - if:
@@ -317,8 +318,8 @@ spawn_rules:
it("does not spawn agents when conditions are not met", () => { it("does not spawn agents when conditions are not met", () => {
const consoleSpy = vi.spyOn(console, "log").mockImplementation(() => {}); const consoleSpy = vi.spyOn(console, "log").mockImplementation(() => {});
// Create a temp file with test spawn rules // Create a temp file with test spawn rules using cross-platform temp directory
const tempPath = "/tmp/test-spawn-rules-2.yml"; const tempPath = path.join(os.tmpdir(), "test-spawn-rules-2.yml");
fs.writeFileSync(tempPath, ` fs.writeFileSync(tempPath, `
spawn_rules: spawn_rules:
- if: - if: