Refactor protocol and utility logic into separate modules

Moved Docker/OCI protocol handling, performance monitoring, security, and validation logic into dedicated modules under src/protocols and src/utils. Updated src/index.js to use these new modules, improving maintainability and separation of concerns. Added pre-computed sorted platform keys for efficient matching in platform config.
This commit is contained in:
xixu-me committed 2025-12-10 15:03:27 +08:00
1 parent 89c8da936d
commit 70ff5b248d
7 files changed
+567 -1015

No files matched your search

+6 -1
View File
@@ -231,7 +231,7 @@ describe('Security Features', () => {
if (response.status >= 400) {
const body = await response.text();
// Should not expose internal paths, stack traces, or sensitive info
expect(body).not.toMatch(/\/[a-zA-Z]:[\\/ /); // Windows paths
expect(body).not.toMatch(/\/[a-zA-Z]:[\\/]/); // Windows paths
expect(body).not.toMatch(/\/home\/[^/]+/); // Unix home paths
expect(body).not.toMatch(/at [a-zA-Z]+\.[a-zA-Z]+/); // Stack traces
expect(body).not.toMatch(/Error: .+ at/); // Detailed error messages
@@ -244,6 +244,11 @@ describe('Security Features', () => {
redirect: 'manual'
});
// Should return error or redirect
expect([400, 404, 302, 301, 405, 501]).toContain(response.status);
});
});
describe('CORS Security', () => {
it('should handle CORS preflight requests securely', async () => {
const response = await SELF.fetch('https://example.com/gh/test/repo', {