권한 체계를 사내 모드 기준으로 정리하고 실행 단위 승인 범위를 바로잡음
사내 모드에서 process/build_run/open_external 경로의 외부 접근 차단 범위를 강화했습니다. http_tool과 외부 URI 차단에 더해 curl, Invoke-WebRequest 같은 네트워크성 명령과 build_run custom 실행을 내부 정책으로 막아 실제 동작이 정책 선언과 더 가깝게 맞춰지도록 했습니다. ChatWindow의 '이번 실행 동안 허용' 승인 규칙을 run-scope로 변경했습니다. 탭 실행 시작과 종료 시 승인 캐시를 초기화하고 같은 실행 안에서만 동일 범위 접근을 재질문 없이 재사용하도록 정리해 창 수명 동안 규칙이 남던 문제를 줄였습니다. 권한 건너뛰기 관련 UI/상태 문구를 실제 동작과 맞췄고, OperationModePolicyTests·OperationModeReadinessTests·AgentLoopE2ETests·LlmOperationModeTests를 통해 권한 정책과 사내 모드 차단 회귀를 검증했습니다. dotnet build 경고 0 / 오류 0, 권한 관련 테스트 49건 통과를 확인했습니다.
This commit is contained in:
@@ -116,6 +116,10 @@ public class BuildRunTool : IAgentTool
|
||||
return ToolResult.Fail($"이 프로젝트 타입({project.Type})에서 '{action}' 작업은 지원되지 않습니다.");
|
||||
}
|
||||
|
||||
if (AxCopilot.Services.OperationModePolicy.IsInternal(context.OperationMode)
|
||||
&& AxCopilot.Services.OperationModePolicy.IsBlockedBuildRunCommandInInternalMode(action, command))
|
||||
return ToolResult.Fail("사내 모드에서는 외부 네트워크 접근 가능성이 있는 빌드/실행 명령이 차단됩니다.");
|
||||
|
||||
// 위험 명령 검사
|
||||
foreach (var pattern in DangerousPatterns)
|
||||
{
|
||||
|
||||
@@ -34,15 +34,14 @@ public class OpenExternalTool : IAgentTool
|
||||
|
||||
try
|
||||
{
|
||||
// URL인 경우
|
||||
if (rawPath.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ||
|
||||
rawPath.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
|
||||
// 외부 URI인 경우
|
||||
if (AxCopilot.Services.OperationModePolicy.IsExternalUri(rawPath))
|
||||
{
|
||||
if (AxCopilot.Services.OperationModePolicy.IsInternal(context.OperationMode))
|
||||
return Task.FromResult(ToolResult.Fail("사내모드에서는 외부 URL 열기가 차단됩니다. operationMode=external에서만 사용할 수 있습니다."));
|
||||
return Task.FromResult(ToolResult.Fail("사내모드에서는 외부 URI 열기가 차단됩니다. operationMode=external에서만 사용할 수 있습니다."));
|
||||
|
||||
Process.Start(new ProcessStartInfo(rawPath) { UseShellExecute = true });
|
||||
return Task.FromResult(ToolResult.Ok($"URL 열기: {rawPath}"));
|
||||
return Task.FromResult(ToolResult.Ok($"외부 URI 열기: {rawPath}"));
|
||||
}
|
||||
|
||||
// 파일/폴더 경로
|
||||
|
||||
@@ -21,25 +21,25 @@ internal static class PermissionModePresentationCatalog
|
||||
PermissionModeCatalog.Default,
|
||||
"\uE8D7",
|
||||
"권한 요청",
|
||||
"변경하기 전에 항상 확인합니다.",
|
||||
"변경하거나 실행하기 전에 항상 확인합니다.",
|
||||
"#2563EB"),
|
||||
new PermissionModePresentation(
|
||||
PermissionModeCatalog.AcceptEdits,
|
||||
"\uE73E",
|
||||
"편집 자동 승인",
|
||||
"모든 파일 편집을 자동 승인합니다.",
|
||||
"편집 자동 허용",
|
||||
"모든 파일 편집은 자동 허용하고, 위험한 실행은 계속 확인합니다.",
|
||||
"#107C10"),
|
||||
new PermissionModePresentation(
|
||||
PermissionModeCatalog.Plan,
|
||||
"\uE769",
|
||||
"계획 모드",
|
||||
"파일을 읽고 분석한 뒤, 실행 전에 계획을 먼저 보여줍니다.",
|
||||
"파일을 바꾸거나 실행하기 전에 계획을 먼저 보여줍니다.",
|
||||
"#D97706"),
|
||||
new PermissionModePresentation(
|
||||
PermissionModeCatalog.BypassPermissions,
|
||||
"\uE814",
|
||||
"권한 건너뛰기",
|
||||
"파일 편집과 명령 실행까지 모두 자동 허용합니다.",
|
||||
"같은 실행 안의 권한 확인을 최대한 생략하지만, 사내 모드에서 지정 경로 밖 접근은 계속 승인받습니다.",
|
||||
"#B45309"),
|
||||
};
|
||||
|
||||
|
||||
@@ -46,6 +46,10 @@ public class ProcessTool : IAgentTool
|
||||
if (string.IsNullOrWhiteSpace(command))
|
||||
return ToolResult.Fail("명령이 비어 있습니다.");
|
||||
|
||||
if (AxCopilot.Services.OperationModePolicy.IsInternal(context.OperationMode)
|
||||
&& AxCopilot.Services.OperationModePolicy.IsBlockedShellCommandInInternalMode(command))
|
||||
return ToolResult.Fail("사내 모드에서는 외부 네트워크 접근 가능성이 있는 명령 실행이 차단됩니다.");
|
||||
|
||||
// 위험 명령 차단
|
||||
foreach (var pattern in DangerousPatterns)
|
||||
{
|
||||
|
||||
@@ -544,7 +544,7 @@ public sealed class AppStateService : IAppStateService
|
||||
"AcceptEdits" => "파일 편집 도구는 자동 허용하고 명령 실행은 계속 확인합니다.",
|
||||
"Deny" => "기존 파일은 읽기만 가능하며 수정/삭제가 차단되고, 새 파일 생성은 가능합니다.",
|
||||
"Plan" => "계획/승인 흐름을 우선 적용한 뒤 파일 작업을 진행합니다.",
|
||||
"BypassPermissions" => "모든 권한 확인을 생략합니다. 주의해서 사용해야 합니다.",
|
||||
"BypassPermissions" => "같은 실행 안의 권한 확인을 최대한 생략하지만, 사내 모드에서 지정 경로 밖 접근은 계속 승인받습니다.",
|
||||
_ => "파일 작업 전마다 사용자 확인을 요청합니다.",
|
||||
};
|
||||
|
||||
|
||||
@@ -7,6 +7,35 @@ public static class OperationModePolicy
|
||||
public const string InternalMode = "internal";
|
||||
public const string ExternalMode = "external";
|
||||
|
||||
private static readonly string[] s_blockedNetworkShellPatterns =
|
||||
[
|
||||
"curl ",
|
||||
"wget ",
|
||||
"invoke-webrequest",
|
||||
"invoke-restmethod",
|
||||
"start-bitstransfer",
|
||||
"bitsadmin ",
|
||||
"ftp ",
|
||||
"tftp ",
|
||||
"scp ",
|
||||
"sftp ",
|
||||
"ssh ",
|
||||
"telnet ",
|
||||
"nc ",
|
||||
"ncat ",
|
||||
"netcat ",
|
||||
"certutil -urlcache",
|
||||
"python -m pip install ",
|
||||
"pip install ",
|
||||
"npm install ",
|
||||
"pnpm add ",
|
||||
"yarn add ",
|
||||
"dotnet add package ",
|
||||
"nuget install ",
|
||||
"mvn dependency:get",
|
||||
"gradle dependency",
|
||||
];
|
||||
|
||||
public static string Normalize(string? mode)
|
||||
{
|
||||
var token = (mode ?? "").Trim().ToLowerInvariant();
|
||||
@@ -25,11 +54,44 @@ public static class OperationModePolicy
|
||||
return true;
|
||||
|
||||
if (string.Equals(toolName, "open_external", StringComparison.OrdinalIgnoreCase))
|
||||
return IsExternalUrl(target);
|
||||
return IsExternalUri(target);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsBlockedShellCommandInInternalMode(string? command)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(command))
|
||||
return false;
|
||||
|
||||
foreach (var pattern in s_blockedNetworkShellPatterns)
|
||||
{
|
||||
if (command.Contains(pattern, StringComparison.OrdinalIgnoreCase))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsBlockedBuildRunCommandInInternalMode(string? action, string? command)
|
||||
{
|
||||
if (string.Equals(action, "custom", StringComparison.OrdinalIgnoreCase))
|
||||
return true;
|
||||
|
||||
return IsBlockedShellCommandInInternalMode(command);
|
||||
}
|
||||
|
||||
public static bool IsExternalUri(string? value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
return false;
|
||||
|
||||
if (!Uri.TryCreate(value, UriKind.Absolute, out var uri))
|
||||
return false;
|
||||
|
||||
return !string.Equals(uri.Scheme, Uri.UriSchemeFile, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public static bool IsExternalUrl(string? value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
|
||||
Reference in New Issue
Block a user