Mac hosting guide

Remove Secrets from Hosted Mac Automation Logs

Log only an allowed list of JSON fields, redact secret patterns when the line is written, and run a corpus of known-bad lines in CI. Any Figment Mac plan can host this, and the Intel VM ($25 a month) is enough.

Figment editorial teamPublished Updated Facts checked November 10, 2026

Figment Mac plans

US East. Pay before use. Hourly and daily too.

Intel Mac VM4 shared vCPUs, 4GB RAM, 80GB SSD$25per monthApple Silicon Mac VM4 shared vCPUs, 4GB RAM, 65GB SSD$39per monthDedicated M4 Pro12-core CPU, 24GB RAM, 512GB SSD$199per month

Minimum first purchase: $25 of account credit, used for your rental.

Keep secrets out of agent logs by allowing only a fixed list of JSON fields, redacting secret patterns at write time, and testing the redactor against a corpus of known-bad lines before the agent ships. A cleanup script run after the fact always lags behind. A Figment Intel Mac VM ($25 a month) is enough to host the agent, the formatter, the corpus test and a nightly scan.

Which Figment Mac plan should host the agent?

The Intel Mac VM suits an agent that writes logs locally and ships them to a central store. It has 4 shared vCPUs, 4GB of RAM and an 80GB SSD on macOS Sequoia, at $25 a month, $2 a day or $0.15 an hour. SSH and remote desktop are included, so editing a launchd plist, writing log-rotation config and tailing a file are all direct.

Move to the Apple Silicon Mac VM ($39 a month) when the agent needs arm64-only tools or Xcode 26.4 or later. Move to the Dedicated M4 Pro 48 GB ($349 a month) when the agent handles sensitive logs and you want a whole Mac that no other customer's VM shares, or when it needs heavier concurrency than shared vCPUs give you.

Figment runs the Mac, network and virtualization layer. The agent, its logs and its log shipping are yours to manage. Prices are in USD before tax.

Where do agent logs land on a Mac?

A launchd user agent writes to the paths you set in StandardOutPath and StandardErrorPath. If you leave them unset, output is discarded. Set both, and keep them inside a directory the agent user owns. See Apple's Creating Launchd Jobs for the full plist key list, including StartCalendarInterval for scheduled runs.

Keep three destinations separate:

DestinationPath patternRedaction needed?
Agent stdout/stderr/Users/agent/logs/agent.log (your choice)Yes. This is the file you control
macOS Unified LogIn-memory ring buffer, persists to /var/db/diagnostics/Conditional. The private specifier hides values
HTTP debug outputurllib3, requests verbose mode, curl -vYes. Authorization headers appear here

Apple's guide to generating log messages documents that dynamic string arguments to os_log and Logger are redacted as <private> by default on release builds, and %{public}s opts an argument back in. That applies to the Unified Log only. Nothing in os_log protects a line you append to agent.log with logging.FileHandler.

Which fields are safe to log?

Have the agent emit one JSON object per line, and decide ahead of time which fields are allowed at all.

FieldTypeSafe to log?Notes
timestampISO 8601 stringYesAlways UTC
jobstringYesAgent job name
run_idstringYesUUID per invocation
statusint / stringYesHTTP status or ok/error
modelstringYese.g. gpt-4o-mini
input_tokensintYesCount only
output_tokensintYesCount only
spent_usdfloat (4 d.p.)YesCost figure, not a key
tool_namestringYesWhich tool was called
tool_args_summarystringConditionalSummarize. Scrub paths with usernames or PII
error_typestringYesException class name
error_messagestringConditionalPass through the redactor before emitting
api_keystringNeverKeep in Keychain or the CI secret manager
authorization_headerstringNeverDo not log HTTP headers at debug in production
request_bodystringNeverMay contain the user's prompt or PII
response_bodystringNeverMay contain sensitive model output
env_dumpstringNeverNever serialize the whole environment to a log

A line that uses only allowed fields:

{"timestamp":"2026-11-10T14:32:01Z","job":"openai-agent","run_id":"a3f8b2c1","status":200,"model":"gpt-4o-mini","input_tokens":1240,"output_tokens":380,"spent_usd":0.0005,"tool_name":"fetch_records","error_type":null}

How do I redact secrets at write time?

Attach a formatter that rewrites known secret shapes before the line reaches the file. For Python agents using the standard logging module:

import logging, re

# Quiet the libraries that like to dump headers at DEBUG.
logging.getLogger("urllib3").setLevel(logging.WARNING)
logging.getLogger("httpcore").setLevel(logging.WARNING)

# Patterns are applied in order. Test every change against the corpus below.
_SECRET_PATTERNS = [
    (re.compile(r"sk-[A-Za-z0-9\-_]{20,}"), "sk-***"),
    (re.compile(r"ghp_[A-Za-z0-9]{36,}"), "ghp_***"),
    (re.compile(r"(?<=Bearer )[A-Za-z0-9\-_.~+/=]{10,}"), "***"),
]

class RedactingFormatter(logging.Formatter):
    def format(self, record: logging.LogRecord) -> str:
        msg = super().format(record)
        for pattern, replacement in _SECRET_PATTERNS:
            msg = pattern.sub(replacement, msg)
        return msg

handler = logging.FileHandler("/Users/agent/logs/agent.log")
handler.setFormatter(RedactingFormatter("%(message)s"))
logging.getLogger().addHandler(handler)

Add a pattern for every credential format the agent handles. These three cover OpenAI-style sk- keys, GitHub personal access tokens and generic Bearer tokens.

How do I test that the redactor works?

Keep a small corpus file of sample strings, some that must be redacted and some that must pass through untouched, and run the formatter against it in CI. Commit the corpus with the code.

# test_corpus.txt
# Format: LINE_TYPE | raw input | expected output after redaction
#
# Lines that MUST be redacted:
SECRET | Authorization: Bearer sk-proj-AbCdEfGhIjKlMnOpQrStUv1234567890ab | Authorization: Bearer sk-***
SECRET | api_key="sk-ant-api03-xyzXYZ1234567890abcdefABCDEF" | api_key="sk-***"
SECRET | OPENAI_API_KEY=sk-proj-testkey12345678901234567890 | OPENAI_API_KEY=sk-***
SECRET | token: ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | token: ghp_***
SECRET | Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6Ikp | Bearer ***
#
# Lines that MUST NOT be changed:
SAFE   | status=200 model=gpt-4o-mini spent_usd=0.0005 | status=200 model=gpt-4o-mini spent_usd=0.0005
SAFE   | error_type=RateLimitError | error_type=RateLimitError
SAFE   | input_tokens=1240 output_tokens=380 | input_tokens=1240 output_tokens=380
SAFE   | job=openai-agent run_id=a3f8b2c1 | job=openai-agent run_id=a3f8b2c1

Run the corpus through the patterns in a test. It must exit non-zero on any mismatch:

# test_redaction.py
import sys
from agent_logging import _SECRET_PATTERNS  # your patterns module

def apply_redaction(text: str) -> str:
    for pattern, replacement in _SECRET_PATTERNS:
        text = pattern.sub(replacement, text)
    return text

failures, checked = [], 0
with open("test_corpus.txt") as f:
    for line in f:
        line = line.strip()
        if not line or line.startswith("#") or "|" not in line:
            continue
        line_type, raw, expected = [p.strip() for p in line.split("|", 2)]
        checked += 1
        result = apply_redaction(raw)
        if result != expected:
            failures.append(f"{line_type}: input={raw!r} expected={expected!r} got={result!r}")

if failures:
    print("\n".join(failures))
    sys.exit(1)
print(f"All {checked} corpus lines passed.")

Every new provider integration earns one or two new corpus lines, and the test fails loudly if a new key shape leaks through.

How do I clean logs written before redaction existed?

Rewrite them once, before you archive or share them:

#!/bin/bash
# redact_existing_log.sh
set -euo pipefail
INPUT="$1"
OUTPUT="${INPUT%.log}-redacted.log"

sed -E \
  -e 's/sk-[A-Za-z0-9_-]{20,}/sk-***/g' \
  -e 's/ghp_[A-Za-z0-9]{36,}/ghp_***/g' \
  -e 's/(Bearer )[A-Za-z0-9_.~+/-]{10,}/\1***/g' \
  "$INPUT" > "$OUTPUT"

diff -u "$INPUT" "$OUTPUT" | head -40
echo "Redacted log written to: $OUTPUT"

The diff preview shows exactly what changed. Keep the original only until you have reviewed it.

How do I check for leaks every night?

Schedule a nightly scan that greps current log files for the known secret shapes and writes a line to a scan log. Use a StartCalendarInterval key at 03:00 to run:

#!/bin/bash
# nightly_secret_scan.sh
set -euo pipefail
LOG_DIR=/Users/agent/logs
PATTERNS='sk-[A-Za-z0-9_-]{20,}|ghp_[A-Za-z0-9]{36,}|Bearer [A-Za-z0-9_.~+/-]{15,}'
STAMP="$(date -u +%FT%TZ)"

if grep -rqE "$PATTERNS" "$LOG_DIR" 2>/dev/null; then
  echo "$STAMP SECRET LEAK DETECTED in $LOG_DIR" >> "$LOG_DIR/security-scan.log"
  exit 1
fi
echo "$STAMP scan clean" >> "$LOG_DIR/security-scan.log"

A hit is a credential-rotation event, not a redaction event. Rotate the leaked key in the issuing system first, then rewrite the affected log files with the post-processor above.

How do I start on a Figment Mac?

Pick a plan on Figment Mac hosting and put the launchd job, the Python formatter, the corpus test and the nightly scan on the Mac. Figment gives you the Mac and access. Where the scan results go, and who reads them, is your setup.

Related reading

Which Figment Mac fits this work?

Intel Mac VM from $25 a month, Apple Silicon Mac VM from $39, or a Dedicated M4 Pro for $199. Hourly and daily plans too. You pay before use, starting with at least $25 of account credit.

Choose a Mac plan