(t *testing.T)
| 190 | } |
| 191 | |
| 192 | func TestValidatePathComponents(t *testing.T) { |
| 193 | tests := []struct { |
| 194 | name string |
| 195 | owner string |
| 196 | repo string |
| 197 | path string |
| 198 | sha string |
| 199 | shouldErr bool |
| 200 | errMsg string |
| 201 | }{ |
| 202 | { |
| 203 | name: "valid components", |
| 204 | owner: "testowner", |
| 205 | repo: "testrepo", |
| 206 | path: "workflows/test.md", |
| 207 | sha: "abc123", |
| 208 | shouldErr: false, |
| 209 | }, |
| 210 | { |
| 211 | name: "empty owner", |
| 212 | owner: "", |
| 213 | repo: "testrepo", |
| 214 | path: "test.md", |
| 215 | sha: "abc123", |
| 216 | shouldErr: true, |
| 217 | errMsg: "empty component", |
| 218 | }, |
| 219 | { |
| 220 | name: "empty sha", |
| 221 | owner: "testowner", |
| 222 | repo: "testrepo", |
| 223 | path: "test.md", |
| 224 | sha: "", |
| 225 | shouldErr: true, |
| 226 | errMsg: "empty component", |
| 227 | }, |
| 228 | { |
| 229 | name: "path traversal in owner", |
| 230 | owner: "../etc", |
| 231 | repo: "testrepo", |
| 232 | path: "test.md", |
| 233 | sha: "abc123", |
| 234 | shouldErr: true, |
| 235 | errMsg: "..", |
| 236 | }, |
| 237 | { |
| 238 | name: "path traversal in path", |
| 239 | owner: "testowner", |
| 240 | repo: "testrepo", |
| 241 | path: "../../etc/passwd", |
| 242 | sha: "abc123", |
| 243 | shouldErr: true, |
| 244 | errMsg: "..", |
| 245 | }, |
| 246 | { |
| 247 | name: "absolute path in sha", |
| 248 | owner: "testowner", |
| 249 | repo: "testrepo", |
nothing calls this directly
no test coverage detected