| 1 | namespace Zipelo.SecurityTests; |
| 2 | |
| 3 | internal static class Program |
| 4 | { |
| 5 | public static async Task<int> Main(string[] arguments) |
| 6 | { |
| 7 | if (arguments.Length != 2) |
| 8 | { |
| 9 | Console.Error.WriteLine("tests/run_checks.py --core로 실행해야 함"); |
| 10 | return 2; |
| 11 | } |
| 12 | |
| 13 | var root = Path.GetFullPath(arguments[0]); |
| 14 | var sandbox = Path.GetFullPath(arguments[1]); |
| 15 | var work = Path.Combine(root, "tests", "security", ".work"); |
| 16 | if (!File.Exists(Path.Combine(root, "src", "Zipelo.Core", "Zipelo.Core.csproj")) || |
| 17 | !sandbox.StartsWith(work + Path.DirectorySeparatorChar, StringComparison.Ordinal) || |
| 18 | !Directory.Exists(sandbox)) |
| 19 | { |
| 20 | Console.Error.WriteLine("프로젝트 안의 테스트 임시 영역이 필요함"); |
| 21 | return 2; |
| 22 | } |
| 23 | |
| 24 | for (DirectoryInfo? directory = new DirectoryInfo(sandbox); directory is not null; directory = directory.Parent) |
| 25 | { |
| 26 | if ((directory.Attributes & FileAttributes.ReparsePoint) != 0) |
| 27 | { |
| 28 | Console.Error.WriteLine("테스트 경로의 링크를 허용하지 않음"); |
| 29 | return 2; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | var tests = new CoreTests(root, sandbox); |
| 34 | var passed = 0; |
| 35 | var failed = 0; |
| 36 | foreach (var (name, run) in tests.Cases()) |
| 37 | { |
| 38 | try |
| 39 | { |
| 40 | await run(); |
| 41 | Console.WriteLine($"PASS {name}"); |
| 42 | passed++; |
| 43 | } |
| 44 | catch (Exception exception) |
| 45 | { |
| 46 | // 예외 원문과 테스트 암호를 출력하지 않음. |
| 47 | Console.Error.WriteLine($"FAIL {name}: {exception.GetType().Name}"); |
| 48 | failed++; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | Console.WriteLine($"코어 회귀 검사: {passed} 통과, {failed} 실패"); |
| 53 | Console.WriteLine("미실행: 실제 엔진, Windows 링크/junction, 저장 계층 경합, 미리보기 실행 및 통신 관찰"); |
| 54 | return failed == 0 ? 0 : 1; |
| 55 | } |
| 56 | } |