Welcome back! In the previous chapter, Trust Verification UI, we met the "Bouncer" (the Trust Dialog). We learned that it stops the application from running in dangerous folders until you give permission.
But here is the million-dollar question: How does the Bouncer know if a folder is dangerous?
Does it guess? Does it flip a coin? No. It uses Capability Inspection Utilities.
If the Trust Dialog is the security guard at the airport, the Capability Inspection Utilities are the X-Ray machines.
When you enter an airport, the guard doesn't stop everyone. They stop people carrying "sharp objects" or prohibited items. In our application, a "sharp object" is a configuration setting that gives the AI too much power, such as:
The Inspection Utilities scan the project's settings files to see if any of these "sharp objects" are packed inside.
Imagine you download a project that has a hidden setting: "Allow AI to delete files using Bash."
These utilities live in utils.ts. Their job is to look at configuration data and return a list of files that contain risky settings.
Here are the specific "sensors" we use:
This is the most critical check. Giving an AI access to bash means it can run almost any command on your computer.
// Simplified concept from utils.ts
function hasBashPermission(rules: PermissionRule[]): boolean {
// Loop through all permissions
return rules.some(rule =>
// Is the rule "allow"? AND Is the tool "bash"?
rule.ruleBehavior === 'allow' &&
rule.ruleValue.toolName === 'bash'
);
}
Explanation:
This function looks through a list of permission rules. If it finds one that explicitly allows bash, it returns true. This raises a red flag.
Some projects set environment variables (like API keys) automatically. We check if the project is trying to set anything unusual.
// Simplified concept from utils.ts
function hasDangerousEnvVars(settings): boolean {
// Get all environment variable keys defined in settings
const keys = Object.keys(settings.env);
// Check if any key is NOT in our "Safe List"
return keys.some(key => !SAFE_ENV_VARS.has(key));
}
Explanation:
We have a list of safe variables (like PORT or HOST). If a project tries to set AWS_SECRET_KEY (which is not safe), this sensor trips the alarm.
The Trust Dialog uses these functions to build a report. It doesn't just want to know if there is a risk; it wants to know where it is coming from (e.g., is it in your project settings or your local settings?).
Here is how we use the utilities to get the source of the danger:
// Usage in TrustDialog.tsx
import { getBashPermissionSources } from './utils';
// Returns an array, e.g., ['.claude/settings.json']
const bashSources = getBashPermissionSources();
if (bashSources.length > 0) {
console.log("Warning: Bash execution enabled in:", bashSources);
// Trigger the Trust Dialog!
}
What happens here?
getBashPermissionSources().length > 0), the UI knows it must ask for trust.Let's look under the hood. How does the utility actually get the data to inspect?
It follows a Pull & Check pattern.
get...Sources Pattern
Most functions in utils.ts follow the exact same structure. They check Project Settings (shared with your team) and Local Settings (private to you).
Here is the actual implementation structure for detecting Git Hooks:
// From utils.ts
export function getHooksSources(): string[] {
const sources: string[] = []
// 1. Inspect Project Settings
const projectSettings = getSettingsForSource('projectSettings')
if (hasHooks(projectSettings)) {
sources.push('.claude/settings.json')
}
// 2. Inspect Local Settings
const localSettings = getSettingsForSource('localSettings')
if (hasHooks(localSettings)) {
sources.push('.claude/settings.local.json')
}
return sources
}
Code Walkthrough:
sources array: We start with an empty list.getSettingsForSource: We fetch the configuration (we will learn how this works in the next chapter).hasHooks(...): We run our "sensor" logic on that configuration.push: If hooks are found, we add the filename to our list.
By returning the filename (e.g., .claude/settings.json), the Trust Dialog can tell the user: "Hey, check the file .claude/settings.json, it looks suspicious." This makes the tool helpful, not just annoying.
In this chapter, we learned:
hasBashPermission, hasHooks) to detect specific risks.true/false; we return the filenames causing the risk so the user can investigate.
But wait... inside these utilities, we kept calling getSettingsForSource(...). Where do these settings come from? How does the app know the difference between "Project Settings" and "Local Settings"?
To find out, proceed to the next chapter: Configuration Source Hierarchy
Generated by Code IQ