(t *testing.T)
| 22 | ) |
| 23 | |
| 24 | func TestCreateNewFileValidation(t *testing.T) { |
| 25 | tests := []struct { |
| 26 | name string |
| 27 | inputPath string |
| 28 | shouldSucceed bool |
| 29 | description string |
| 30 | }{ |
| 31 | { |
| 32 | name: "Valid absolute path", |
| 33 | inputPath: "/tmp/test/model.bin", |
| 34 | shouldSucceed: true, |
| 35 | description: "Should allow valid absolute paths", |
| 36 | }, |
| 37 | { |
| 38 | name: "Valid relative path", |
| 39 | inputPath: "models/pytorch_model.bin", |
| 40 | shouldSucceed: true, |
| 41 | description: "Should allow valid relative paths", |
| 42 | }, |
| 43 | { |
| 44 | name: "Current directory reference", |
| 45 | inputPath: ".", |
| 46 | shouldSucceed: false, |
| 47 | description: "Should reject current directory reference", |
| 48 | }, |
| 49 | { |
| 50 | name: "Parent directory reference", |
| 51 | inputPath: "..", |
| 52 | shouldSucceed: false, |
| 53 | description: "Should reject parent directory reference", |
| 54 | }, |
| 55 | { |
| 56 | name: "Empty string", |
| 57 | inputPath: "", |
| 58 | shouldSucceed: false, |
| 59 | description: "Should reject empty paths", |
| 60 | }, |
| 61 | { |
| 62 | name: "Path that resolves to current dir", |
| 63 | inputPath: "./././.", |
| 64 | shouldSucceed: false, |
| 65 | description: "Should reject paths that resolve to current directory", |
| 66 | }, |
| 67 | { |
| 68 | name: "Path that resolves to parent dir", |
| 69 | inputPath: "../../../..", |
| 70 | shouldSucceed: false, |
| 71 | description: "Should reject paths that resolve to parent directory", |
| 72 | }, |
| 73 | { |
| 74 | name: "Path with traversal but valid destination", |
| 75 | inputPath: "/tmp/../model.bin", |
| 76 | shouldSucceed: false, |
| 77 | description: "Should reject any path containing '..' even if it resolves to valid location", |
| 78 | }, |
| 79 | // Protected paths test cases |
| 80 | { |
| 81 | name: "Direct /etc path", |
nothing calls this directly
no test coverage detected