fix(git): ::/96 in SSRF-BlockList, URL-Tests für IPv6-Literale, ESLint no-nested-ternary
Re-Review PR #19: IPv4-kompatible Adressen (::7f00:1) fehlten in der BlockList, CI scheiterte an einem verschachtelten Ternary in editorPage.jsx. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
de3f157e18
commit
7e638ec8a1
3 files changed
+10
-4
No files matched your search
@@ -214,7 +214,8 @@ const EditorPage = (props)=>{
|
||||
clearTimeout(saveTimeout.current);
|
||||
if(isSaving) return;
|
||||
if(!forceSave && !hasChanges) return;
|
||||
const newTimeout = forceSave ? 0 : (gitLinked ? GIT_SAVE_TIMEOUT : SAVE_TIMEOUT);
|
||||
const autoSaveTimeout = gitLinked ? GIT_SAVE_TIMEOUT : SAVE_TIMEOUT; // [fork] ADR-0003 F6
|
||||
const newTimeout = forceSave ? 0 : autoSaveTimeout;
|
||||
|
||||
saveTimeout.current = setTimeout(async ()=>{
|
||||
setIsSaving(true);
|
||||
|
||||
@@ -81,7 +81,7 @@ describe('URL-Policy (SSRF)', ()=>{
|
||||
await expect(assertUrlAllowed('https://git.example.test:8443/a/b.git', cfg, { lookup: pub })).resolves.toBeDefined();
|
||||
});
|
||||
|
||||
test.each(['127.0.0.1', '10.1.2.3', '172.16.0.1', '172.31.255.255', '192.168.1.1', '169.254.169.254', '100.64.0.1', '0.0.0.0', '::1', 'fd00::1', 'fe80::1', '::ffff:127.0.0.1', '::ffff:7f00:1', '::ffff:a9fe:a9fe', '::ffff:10.0.0.1', '0:0:0:0:0:ffff:7f00:1', '64:ff9b::7f00:1', '224.0.0.1'])('%s gilt als intern', (ip)=>{
|
||||
test.each(['127.0.0.1', '10.1.2.3', '172.16.0.1', '172.31.255.255', '192.168.1.1', '169.254.169.254', '100.64.0.1', '0.0.0.0', '::1', 'fd00::1', 'fe80::1', '::ffff:127.0.0.1', '::ffff:7f00:1', '::ffff:a9fe:a9fe', '::ffff:10.0.0.1', '0:0:0:0:0:ffff:7f00:1', '64:ff9b::7f00:1', '::7f00:1', '::a9fe:a9fe', '224.0.0.1'])('%s gilt als intern', (ip)=>{
|
||||
expect(isPrivateAddress(ip)).toBe(true);
|
||||
});
|
||||
test.each(['8.8.8.8', '93.184.216.34', '172.32.0.1', '2606:4700::1111'])('%s gilt als öffentlich', (ip)=>{
|
||||
@@ -95,6 +95,10 @@ describe('URL-Policy (SSRF)', ()=>{
|
||||
await expect(assertUrlAllowed('https://[::1]/a/b', cfg, { lookup: pub })).rejects.toThrow();
|
||||
});
|
||||
|
||||
test.each(['[::ffff:127.0.0.1]', '[::ffff:a9fe:a9fe]', '[::ffff:10.0.0.1]', '[64:ff9b::7f00:1]', '[::7f00:1]'])('IPv6-Literal %s in der URL wird abgelehnt', async (host)=>{
|
||||
await expect(assertUrlAllowed(`https://${host}/a/b.git`, cfg, { lookup: pub })).rejects.toMatchObject({ HBErrorCode: 'G08' });
|
||||
});
|
||||
|
||||
test('HB_GIT_ALLOW_PRIVATE erlaubt interne Ziele, HB_GIT_ALLOW_HTTP http://', async ()=>{
|
||||
await expect(assertUrlAllowed('http://127.0.0.1:3000/a/b', { ...cfg, allowPrivate: true, allowHttp: true })).resolves.toBeDefined();
|
||||
expect(()=>parseRepoUrl('http://x.test/a/b', { allowHttp: true })).not.toThrow();
|
||||
|
||||
@@ -24,11 +24,12 @@ const blocked = new net.BlockList();
|
||||
['172.16.0.0', 12], ['192.0.0.0', 24], ['192.168.0.0', 16], ['198.18.0.0', 15], ['224.0.0.0', 3]
|
||||
].forEach(([n, p])=>blocked.addSubnet(n, p, 'ipv4'));
|
||||
[
|
||||
['::', 128], ['::1', 128], ['fc00::', 7], ['fe80::', 10], ['ff00::', 8],
|
||||
// IPv4-gemappte Adressen (::ffff:a.b.c.d / ::ffff:a9fe:a9fe) prüft BlockList selbst gegen die IPv4-Regeln
|
||||
['::', 96], // IPv4-kompatibel (::a.b.c.d), schließt :: und ::1 ein
|
||||
['::1', 128], ['fc00::', 7], ['fe80::', 10], ['ff00::', 8],
|
||||
['64:ff9b::', 96], // NAT64
|
||||
['2002::', 16] // 6to4
|
||||
].forEach(([n, p])=>blocked.addSubnet(n, p, 'ipv6'));
|
||||
// IPv4-gemappte Adressen (::ffff:a.b.c.d, auch als ::ffff:7f00:1) prüft BlockList selbst gegen die IPv4-Regeln.
|
||||
|
||||
export const isPrivateAddress = (address)=>{
|
||||
const ip = String(address).toLowerCase().replace(/^\[|\]$/g, '').split('%')[0];
|
||||
|
||||
Reference in new issue
Block a user