Documentation
¶
Overview ¶
blocked_paths.go provides file path blocking functionality for HostMCP. It prevents AI assistants from reading sensitive files like secrets, API keys, and configuration files.
blocked_paths.goはHostMCPのファイルパスブロック機能を提供します。 AIアシスタントがシークレット、APIキー、設定ファイルなどの 機密ファイルを読むことを防ぎます。
Blocked paths can come from multiple sources: ブロックパスは複数のソースから取得できます:
- Manual configuration in hostmcp.yaml (hostmcp.yamlでの手動設定)
- Global patterns (グローバルパターン)
- Auto-import from DevContainer configs (DevContainer設定からの自動インポート)
- Claude Code settings files (Claude Code設定ファイル)
Package security provides the HostCommandPolicy for host CLI command execution. It enforces whitelist-based access control with deny lists and dangerous mode.
securityパッケージはホストCLIコマンド実行のためのHostCommandPolicyを提供します。 ホワイトリストベースのアクセス制御と拒否リストおよび危険モードを適用します。
Package security provides security policy enforcement for HostMCP. It controls which containers can be accessed, what operations are allowed, and which commands can be executed.
securityパッケージはHostMCPのセキュリティポリシー適用を提供します。 どのコンテナにアクセスできるか、どの操作が許可されるか、 どのコマンドを実行できるかを制御します。
Security Modes (セキュリティモード):
- strict: Only explicitly allowed containers/commands (最も厳格)
- moderate: Balanced security with whitelist enforcement (バランス型)
- permissive: Less restrictive, more access allowed (緩和型)
Index ¶
- type BlockedPath
- type BlockedPathsManager
- func (m *BlockedPathsManager) AddBlockedPath(blocked BlockedPath)
- func (m *BlockedPathsManager) GetBlockedPaths() []BlockedPath
- func (m *BlockedPathsManager) GetBlockedPathsForContainer(containerName string) []BlockedPath
- func (m *BlockedPathsManager) IsPathBlocked(containerName string, path string) *BlockedPath
- func (m *BlockedPathsManager) LoadBlockedPaths() error
- func (m *BlockedPathsManager) SetContainers(containers []string)
- type ClaudeCodePermissions
- type ClaudeCodeSettings
- type DockerComposeConfig
- type DockerComposeService
- type HostCommandPolicy
- type OutputMasker
- func (m *OutputMasker) AddPattern(pattern string) error
- func (m *OutputMasker) IsEnabled() bool
- func (m *OutputMasker) MaskExec(output string) string
- func (m *OutputMasker) MaskInspect(output string) string
- func (m *OutputMasker) MaskLogs(output string) string
- func (m *OutputMasker) MaskOutput(output string) string
- func (m *OutputMasker) PatternCount() int
- func (m *OutputMasker) ShouldMaskExec() bool
- func (m *OutputMasker) ShouldMaskInspect() bool
- func (m *OutputMasker) ShouldMaskLogs() bool
- type Policy
- func (p *Policy) CanAccessContainer(containerName string) bool
- func (p *Policy) CanExec(containerName string, command string) (bool, error)
- func (p *Policy) CanExecDangerously(containerName string, command string) (bool, error)
- func (p *Policy) CanGetLogs() bool
- func (p *Policy) CanGetStats() bool
- func (p *Policy) CanInspect() bool
- func (p *Policy) CanLifecycle(containerName string) (bool, error)
- func (p *Policy) GetAllContainersWithCommands() map[string][]string
- func (p *Policy) GetAllDangerousCommands() map[string][]string
- func (p *Policy) GetAllowedCommands(containerName string) []string
- func (p *Policy) GetBlockedPaths() []BlockedPath
- func (p *Policy) GetBlockedPathsForContainer(containerName string) []BlockedPath
- func (p *Policy) GetDangerousCommandsForContainer(containerName string) []string
- func (p *Policy) GetMode() string
- func (p *Policy) GetOutputMaskingStatus() map[string]any
- func (p *Policy) GetSecurityPolicy() map[string]any
- func (p *Policy) InitBlockedPaths(containers []string) error
- func (p *Policy) IsDangerousModeEnabled() bool
- func (p *Policy) IsHostPathMaskingEnabled() bool
- func (p *Policy) IsPathBlocked(containerName string, path string) *BlockedPath
- func (p *Policy) MaskExec(output string) string
- func (p *Policy) MaskHostPaths(input string) string
- func (p *Policy) MaskInspect(output string) string
- func (p *Policy) MaskLogs(output string) string
- func (p *Policy) SetDangerousCommands(containerName string, commands []string)
- func (p *Policy) SetDangerousModeEnabled(enabled bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockedPath ¶
type BlockedPath struct {
// Container is the container name this path applies to, or "*" for all
// Containerはこのパスが適用されるコンテナ名、または全てに適用する場合は"*"
Container string `json:"container"`
// Pattern is the file path pattern to block (supports globs)
// Patternはブロックするファイルパスパターン(globをサポート)
Pattern string `json:"pattern"`
// Reason explains why this path is blocked (e.g., "manual_block", "global_pattern")
// Reasonはこのパスがブロックされている理由を説明します(例: "manual_block", "global_pattern")
Reason string `json:"reason"`
// Source is the file where this block was defined (e.g., "hostmcp.yaml")
// Sourceはこのブロックが定義されたファイルです(例: "hostmcp.yaml")
Source string `json:"source,omitempty"`
// SourceLine is the line number in the source file (if available)
// SourceLineはソースファイル内の行番号です(利用可能な場合)
SourceLine int `json:"source_line,omitempty"`
// OriginalPath is the original path before normalization (for debugging)
// OriginalPathは正規化前の元のパスです(デバッグ用)
OriginalPath string `json:"original_path,omitempty"`
}
BlockedPath represents a blocked file path with metadata about why it's blocked. This information is used for debugging and to provide meaningful error messages.
BlockedPathはブロックされたファイルパスとブロック理由のメタデータを表します。 この情報はデバッグと意味のあるエラーメッセージの提供に使用されます。
type BlockedPathsManager ¶
type BlockedPathsManager struct {
// contains filtered or unexported fields
}
BlockedPathsManager manages blocked file paths for all containers. It loads paths from configuration and provides path checking functionality.
BlockedPathsManagerは全コンテナのブロックファイルパスを管理します。 設定からパスをロードし、パスチェック機能を提供します。
func NewBlockedPathsManager ¶
func NewBlockedPathsManager(cfg *config.BlockedPathsConfig, containers []string) *BlockedPathsManager
NewBlockedPathsManager creates a new blocked paths manager. The containers parameter is used to match container names in path patterns.
NewBlockedPathsManagerは新しいブロックパスマネージャを作成します。 containersパラメータはパスパターン内のコンテナ名のマッチングに使用されます。
func (*BlockedPathsManager) AddBlockedPath ¶
func (m *BlockedPathsManager) AddBlockedPath(blocked BlockedPath)
AddBlockedPath adds a blocked path manually. This can be used to add paths programmatically.
AddBlockedPathはブロックパスを手動で追加します。 これはプログラムでパスを追加するために使用できます.
func (*BlockedPathsManager) GetBlockedPaths ¶
func (m *BlockedPathsManager) GetBlockedPaths() []BlockedPath
GetBlockedPaths returns all blocked paths from all sources. GetBlockedPathsは全ソースからの全ブロックパスを返します。
func (*BlockedPathsManager) GetBlockedPathsForContainer ¶
func (m *BlockedPathsManager) GetBlockedPathsForContainer(containerName string) []BlockedPath
GetBlockedPathsForContainer returns blocked paths applicable to a specific container. Includes both container-specific paths and global patterns (Container = "*").
GetBlockedPathsForContainerは特定のコンテナに適用されるブロックパスを返します。 コンテナ固有のパスとグローバルパターン(Container = "*")の両方を含みます。
func (*BlockedPathsManager) IsPathBlocked ¶
func (m *BlockedPathsManager) IsPathBlocked(containerName string, path string) *BlockedPath
IsPathBlocked checks if a file path is blocked for a specific container. Returns BlockedPath info if blocked, nil if allowed.
IsPathBlockedはファイルパスが特定のコンテナに対してブロックされているかチェックします。 ブロックされている場合はBlockedPath情報を返し、許可されている場合はnilを返します。
func (*BlockedPathsManager) LoadBlockedPaths ¶
func (m *BlockedPathsManager) LoadBlockedPaths() error
LoadBlockedPaths loads all blocked paths from configuration and auto-import sources. This should be called once during initialization.
LoadBlockedPathsは設定と自動インポートソースから全てのブロックパスをロードします。 これは初期化時に一度呼び出す必要があります。
func (*BlockedPathsManager) SetContainers ¶
func (m *BlockedPathsManager) SetContainers(containers []string)
SetContainers updates the known container list. This should be called when the container list changes.
SetContainersは既知のコンテナリストを更新します。 コンテナリストが変更された場合にこれを呼び出す必要があります。
type ClaudeCodePermissions ¶
type ClaudeCodePermissions struct {
// Deny contains patterns that should be denied (e.g., "Read(.env)")
// Denyには拒否すべきパターンが含まれます(例: "Read(.env)")
Deny []string `json:"deny"`
// Allow contains patterns that are explicitly allowed
// Allowには明示的に許可されたパターンが含まれます
Allow []string `json:"allow"`
}
ClaudeCodePermissions represents the permissions section in Claude Code settings. The deny list contains patterns that should be blocked.
ClaudeCodePermissionsはClaude Code設定のpermissionsセクションを表します。 denyリストにはブロックすべきパターンが含まれます。
type ClaudeCodeSettings ¶
type ClaudeCodeSettings struct {
// Permissions contains allow/deny lists for operations
// Permissionsは操作の許可/拒否リストを含みます
Permissions ClaudeCodePermissions `json:"permissions"`
}
ClaudeCodeSettings represents the Claude Code settings.json structure. This is used to import blocked paths from Claude Code configuration.
ClaudeCodeSettingsはClaude Codeのsettings.json構造を表します。 これはClaude Code設定からブロックパスをインポートするために使用されます。
type DockerComposeConfig ¶
type DockerComposeConfig struct {
// Services maps service names to their configurations
// Servicesはサービス名からその設定へのマップです
Services map[string]DockerComposeService `yaml:"services"`
}
DockerComposeConfig represents a partial docker-compose.yml structure. Only the fields needed for blocked path detection are included.
DockerComposeConfigはdocker-compose.ymlの部分的な構造を表します。 ブロックパス検出に必要なフィールドのみが含まれています。
type DockerComposeService ¶
type DockerComposeService struct {
// Volumes contains volume mount specifications
// Volumesはボリュームマウント仕様を含みます
Volumes []string `yaml:"volumes"`
// Tmpfs contains tmpfs mount paths
// Tmpfsはtmpfsマウントパスを含みます
Tmpfs []string `yaml:"tmpfs"`
}
DockerComposeService represents a service in docker-compose.yml. We only need volumes and tmpfs for blocked path detection.
DockerComposeServiceはdocker-compose.ymlのサービスを表します。 ブロックパス検出にはvolumesとtmpfsのみが必要です。
type HostCommandPolicy ¶
type HostCommandPolicy struct {
// contains filtered or unexported fields
}
HostCommandPolicy enforces security rules for host command execution. HostCommandPolicyはホストコマンド実行のセキュリティルールを適用します。
func NewHostCommandPolicy ¶
func NewHostCommandPolicy(cfg *config.HostCommandsConfig) *HostCommandPolicy
NewHostCommandPolicy creates a new HostCommandPolicy from config. NewHostCommandPolicyは設定から新しいHostCommandPolicyを作成します。
func (*HostCommandPolicy) CanExecHostCommand ¶
func (p *HostCommandPolicy) CanExecHostCommand(command string) (bool, error)
CanExecHostCommand checks if a command is allowed in normal mode. Checks: docker rejection + whitelist match + deny check + pipe/redirect check.
CanExecHostCommandは通常モードでコマンドが許可されているかチェックします。 チェック: docker拒否 + ホワイトリストマッチ + 拒否チェック + パイプ/リダイレクトチェック
func (*HostCommandPolicy) CanExecHostCommandDangerously ¶
func (p *HostCommandPolicy) CanExecHostCommandDangerously(command string) (bool, error)
CanExecHostCommandDangerously checks if a command is allowed in dangerous mode. CanExecHostCommandDangerouslyは危険モードでコマンドが許可されているかチェックします。
func (*HostCommandPolicy) GetAllowedHostCommands ¶
func (p *HostCommandPolicy) GetAllowedHostCommands() map[string][]string
GetAllowedHostCommands returns the whitelist of allowed host commands. GetAllowedHostCommandsは許可されたホストコマンドのホワイトリストを返します。
type OutputMasker ¶
type OutputMasker struct {
// contains filtered or unexported fields
}
OutputMasker applies masking rules to command output to hide sensitive data. It uses compiled regex patterns for efficient matching.
OutputMaskerはコマンド出力にマスキングルールを適用して機密データを隠します。 効率的なマッチングのためにコンパイル済み正規表現パターンを使用します。
func NewOutputMasker ¶
func NewOutputMasker(cfg *config.OutputMaskingConfig) (*OutputMasker, error)
NewOutputMasker creates a new OutputMasker from configuration. It compiles all regex patterns and validates them.
NewOutputMaskerは設定から新しいOutputMaskerを作成します。 すべての正規表現パターンをコンパイルして検証します。
func (*OutputMasker) AddPattern ¶
func (m *OutputMasker) AddPattern(pattern string) error
AddPattern adds a new masking pattern at runtime. Returns an error if the pattern is invalid.
AddPatternは実行時に新しいマスキングパターンを追加します。 パターンが無効な場合はエラーを返します。
func (*OutputMasker) IsEnabled ¶
func (m *OutputMasker) IsEnabled() bool
IsEnabled returns true if output masking is enabled. IsEnabledは出力マスキングが有効な場合にtrueを返します。
func (*OutputMasker) MaskExec ¶
func (m *OutputMasker) MaskExec(output string) string
MaskExec masks sensitive data in exec output if exec masking is enabled. MaskExecはexecマスキングが有効な場合、exec出力内の機密データをマスクします。
func (*OutputMasker) MaskInspect ¶
func (m *OutputMasker) MaskInspect(output string) string
MaskInspect masks sensitive data in inspect output if inspect masking is enabled. MaskInspectはinspectマスキングが有効な場合、inspect出力内の機密データをマスクします。
func (*OutputMasker) MaskLogs ¶
func (m *OutputMasker) MaskLogs(output string) string
MaskLogs masks sensitive data in log output if logs masking is enabled. MaskLogsはログマスキングが有効な場合、ログ出力内の機密データをマスクします。
func (*OutputMasker) MaskOutput ¶
func (m *OutputMasker) MaskOutput(output string) string
MaskOutput applies all masking patterns to the given output string. Returns the masked output.
MaskOutputは指定された出力文字列にすべてのマスキングパターンを適用します。 マスクされた出力を返します。
func (*OutputMasker) PatternCount ¶
func (m *OutputMasker) PatternCount() int
PatternCount returns the number of active masking patterns. PatternCountはアクティブなマスキングパターンの数を返します。
func (*OutputMasker) ShouldMaskExec ¶
func (m *OutputMasker) ShouldMaskExec() bool
ShouldMaskExec returns true if exec output should be masked. ShouldMaskExecはexec出力をマスクすべき場合にtrueを返します。
func (*OutputMasker) ShouldMaskInspect ¶
func (m *OutputMasker) ShouldMaskInspect() bool
ShouldMaskInspect returns true if inspect output should be masked. ShouldMaskInspectはinspect出力をマスクすべき場合にtrueを返します。
func (*OutputMasker) ShouldMaskLogs ¶
func (m *OutputMasker) ShouldMaskLogs() bool
ShouldMaskLogs returns true if logs output should be masked. ShouldMaskLogsはログ出力をマスクすべき場合にtrueを返します。
type Policy ¶
type Policy struct {
// contains filtered or unexported fields
}
Policy handles security policy enforcement for all HostMCP operations. It evaluates requests against the configured security rules and determines whether access should be granted or denied.
Policyは全てのHostMCP操作に対するセキュリティポリシー適用を処理します。 設定されたセキュリティルールに対してリクエストを評価し、 アクセスを許可するか拒否するかを決定します。
func NewPolicy ¶
func NewPolicy(cfg *config.SecurityConfig) *Policy
NewPolicy creates a new security policy with the given configuration. The policy is initialized but blocked paths are not loaded until InitBlockedPaths is called with the container list.
NewPolicyは指定された設定で新しいセキュリティポリシーを作成します。 ポリシーは初期化されますが、ブロックパスはコンテナリストを指定して InitBlockedPathsを呼び出すまでロードされません。
func (*Policy) CanAccessContainer ¶
CanAccessContainer checks if a container can be accessed based on the allowed list. Uses glob pattern matching (e.g., "app-*" matches "app-web", "app-api"). If no allowed list is configured, all containers are accessible.
CanAccessContainerは許可リストに基づいてコンテナにアクセスできるかチェックします。 globパターンマッチングを使用します(例: "app-*"は"app-web"、"app-api"にマッチ)。 許可リストが設定されていない場合、全てのコンテナにアクセス可能です。
func (*Policy) CanExec ¶
CanExec checks if executing a command in a container is allowed. This involves multiple checks:
- Is exec globally enabled? (permissions.exec)
- Is the container accessible? (allowed_containers)
- Does the security mode allow exec?
- Is the command whitelisted? (in moderate mode)
CanExecはコンテナ内でのコマンド実行が許可されているかチェックします。 これは複数のチェックを含みます:
- execがグローバルに有効か?(permissions.exec)
- コンテナにアクセス可能か?(allowed_containers)
- セキュリティモードがexecを許可しているか?
- コマンドがホワイトリストに登録されているか?(moderateモード)
func (*Policy) CanExecDangerously ¶
CanExecDangerously checks if a command can be executed in dangerous mode. This allows commands like tail, grep, cat that are not in the whitelist, but enforces blocked_paths restrictions on file paths in the command.
Security checks performed:
- Is exec_dangerously globally enabled?
- Is exec globally enabled?
- Is the container accessible?
- Is the base command in exec_dangerously.commands list?
- Are there any pipes or redirects? (forbidden)
- Does the command contain path traversal (..)? (forbidden)
- Are all file paths in the command allowed (not in blocked_paths)?
CanExecDangerouslyは危険モードでコマンドを実行できるかチェックします。 ホワイトリストにないtail、grep、catなどのコマンドを許可しますが、 コマンド内のファイルパスにblocked_pathsの制限を適用します。
実行されるセキュリティチェック:
- exec_dangerouslyがグローバルに有効か?
- execがグローバルに有効か?
- コンテナにアクセス可能か?
- ベースコマンドがexec_dangerously.commandsリストにあるか?
- パイプやリダイレクトがあるか?(禁止)
- コマンドにパストラバーサル(..)が含まれるか?(禁止)
- コマンド内の全ファイルパスが許可されているか(blocked_pathsにないか)?
func (*Policy) CanGetLogs ¶
CanGetLogs checks if retrieving container logs is allowed. This is controlled by the permissions.logs setting.
CanGetLogsはコンテナログの取得が許可されているかチェックします。 これはpermissions.logs設定で制御されます。
func (*Policy) CanGetStats ¶
CanGetStats checks if retrieving container stats is allowed. This is controlled by the permissions.stats setting.
CanGetStatsはコンテナ統計の取得が許可されているかチェックします。 これはpermissions.stats設定で制御されます。
func (*Policy) CanInspect ¶
CanInspect checks if container inspection is allowed. This is controlled by the permissions.inspect setting.
CanInspectはコンテナ検査が許可されているかチェックします。 これはpermissions.inspect設定で制御されます。
func (*Policy) CanLifecycle ¶
CanLifecycle checks if container lifecycle operations (start/stop/restart) are allowed for the specified container. Uses Docker API directly (no shell execution).
This involves multiple checks:
- Is lifecycle globally enabled? (permissions.lifecycle)
- Is the container accessible? (allowed_containers)
- Does the security mode allow lifecycle? (denied in strict mode)
CanLifecycleはコンテナのライフサイクル操作(start/stop/restart)が 指定されたコンテナに対して許可されているかチェックします。 Docker APIを直接使用します(シェル実行なし)。
func (*Policy) GetAllContainersWithCommands ¶
GetAllContainersWithCommands returns all containers that have whitelisted commands. Returns a map of container name to list of allowed commands. Includes the special "*" entry for global commands.
GetAllContainersWithCommandsはホワイトリストコマンドを持つ全コンテナを返します。 コンテナ名から許可コマンドリストへのマップを返します。 グローバルコマンドの特別な"*"エントリを含みます。
func (*Policy) GetAllDangerousCommands ¶
GetAllDangerousCommands returns a map of all containers and their dangerous commands. Returns a map of container name to list of dangerous commands. Includes the special "*" entry for global commands.
GetAllDangerousCommandsはすべてのコンテナとそれぞれの危険コマンドのマップを返します。 コンテナ名から危険コマンドリストへのマップを返します。 グローバルコマンドの特別な"*"エントリを含みます。
func (*Policy) GetAllowedCommands ¶
GetAllowedCommands returns all commands allowed for a specific container. Includes both container-specific commands and global commands (*).
GetAllowedCommandsは特定のコンテナに許可された全コマンドを返します。 コンテナ固有のコマンドとグローバルコマンド(*)の両方を含みます。
func (*Policy) GetBlockedPaths ¶
func (p *Policy) GetBlockedPaths() []BlockedPath
GetBlockedPaths returns all configured blocked paths across all containers. Useful for debugging and displaying security configuration.
GetBlockedPathsは全コンテナの全てのブロックパス設定を返します。 デバッグやセキュリティ設定の表示に便利です。
func (*Policy) GetBlockedPathsForContainer ¶
func (p *Policy) GetBlockedPathsForContainer(containerName string) []BlockedPath
GetBlockedPathsForContainer returns blocked paths for a specific container. Includes both container-specific paths and global patterns (marked with "*").
GetBlockedPathsForContainerは特定のコンテナのブロックパスを返します。 コンテナ固有のパスとグローバルパターン("*"でマーク)の両方を含みます。
func (*Policy) GetDangerousCommandsForContainer ¶
GetDangerousCommandsForContainer returns the dangerous commands allowed for a container. Includes both container-specific commands and global commands (*).
GetDangerousCommandsForContainerはコンテナで許可される危険コマンドを返します。 コンテナ固有のコマンドとグローバルコマンド(*)の両方を含みます。
func (*Policy) GetMode ¶
GetMode returns the current security mode (strict/moderate/permissive). GetModeは現在のセキュリティモード(strict/moderate/permissive)を返します。
func (*Policy) GetOutputMaskingStatus ¶
GetOutputMaskingStatus returns the current output masking configuration status. GetOutputMaskingStatusは現在の出力マスキング設定状態を返します。
func (*Policy) GetSecurityPolicy ¶
GetSecurityPolicy returns the current security policy configuration as a map. This is useful for exposing the policy via the MCP get_security_policy tool.
GetSecurityPolicyは現在のセキュリティポリシー設定をマップとして返します。 これはMCPのget_security_policyツール経由でポリシーを公開するのに便利です。
func (*Policy) InitBlockedPaths ¶
InitBlockedPaths initializes the blocked paths manager with the given container list. This must be called before using path blocking features. The container list is used to match container names in path patterns.
InitBlockedPathsは指定されたコンテナリストでブロックパスマネージャを初期化します。 パスブロック機能を使用する前にこれを呼び出す必要があります。 コンテナリストはパスパターン内のコンテナ名のマッチングに使用されます。
func (*Policy) IsDangerousModeEnabled ¶
IsDangerousModeEnabled returns whether dangerous mode is globally enabled. IsDangerousModeEnabledは危険モードがグローバルに有効かを返します。
func (*Policy) IsHostPathMaskingEnabled ¶
IsHostPathMaskingEnabled returns whether host path masking is enabled. IsHostPathMaskingEnabledはホストパスマスキングが有効かを返します。
func (*Policy) IsPathBlocked ¶
func (p *Policy) IsPathBlocked(containerName string, path string) *BlockedPath
IsPathBlocked checks if a file path is blocked for a specific container. Returns BlockedPath info if blocked, nil if allowed. This is used to prevent AI from reading sensitive files.
IsPathBlockedはファイルパスが特定のコンテナに対してブロックされているかチェックします。 ブロックされている場合はBlockedPath情報を返し、許可されている場合はnilを返します。 これはAIが機密ファイルを読むことを防ぐために使用されます。
func (*Policy) MaskExec ¶
MaskExec masks sensitive data in exec command output. Returns the original string if masking is disabled or masker is not initialized.
MaskExecはexecコマンド出力内の機密データをマスクします。 マスキングが無効またはマスカーが初期化されていない場合は元の文字列を返します。
func (*Policy) MaskHostPaths ¶
MaskHostPaths masks host OS paths in the given string. This is used to hide the host OS username and directory structure from AI assistants. Only applies when host_path_masking is enabled in the security configuration.
Masking rules:
- /Users/<username>/... → [HOST_PATH]/...
- /home/<username>/... → [HOST_PATH]/...
- C:\Users\<username>\... → [HOST_PATH]\...
MaskHostPathsは指定された文字列内のホストOSパスをマスクします。 これはAIアシスタントからホストOSのユーザー名やディレクトリ構造を隠すために使用されます。 セキュリティ設定でhost_path_maskingが有効な場合のみ適用されます。
マスキングルール:
- /Users/<username>/... → [HOST_PATH]/...
- /home/<username>/... → [HOST_PATH]/...
- C:\Users\<username>\... → [HOST_PATH]\...
func (*Policy) MaskInspect ¶
MaskInspect masks sensitive data in container inspection output. Returns the original string if masking is disabled or masker is not initialized.
MaskInspectはコンテナ検査出力内の機密データをマスクします。 マスキングが無効またはマスカーが初期化されていない場合は元の文字列を返します。
func (*Policy) MaskLogs ¶
MaskLogs masks sensitive data in log output. Returns the original string if masking is disabled or masker is not initialized.
MaskLogsはログ出力内の機密データをマスクします。 マスキングが無効またはマスカーが初期化されていない場合は元の文字列を返します。
func (*Policy) SetDangerousCommands ¶
SetDangerousCommands sets the dangerous commands for specific containers at runtime. Pass "*" as container name to set global commands. This allows CLI flags to override the config file setting.
SetDangerousCommandsは実行時に特定のコンテナの危険コマンドを設定します。 コンテナ名に"*"を渡すとグローバルコマンドを設定できます。 これによりCLIフラグが設定ファイルの設定を上書きできます。
func (*Policy) SetDangerousModeEnabled ¶
SetDangerousModeEnabled enables or disables dangerous mode at runtime. This allows CLI flags to override the config file setting.
SetDangerousModeEnabledは実行時に危険モードを有効/無効にします。 これによりCLIフラグが設定ファイルの設定を上書きできます。