mirror of
https://github.com/lunchcat/sif.git
synced 2026-07-28 14:37:01 -07:00
* refactor: share one helper for the per-user sif config directory the modules loader and the framework custom-signature loader each hand-rolled the same ~/.config/sif/<sub> (and %LocalAppData%\sif\<sub> on windows) path. extract internal/sifpath.UserSubdir and route both through it so the per-user layout is defined in one place. no behavior change: the helper reproduces the existing paths exactly. * refactor: read capped response bodies through one httpx helper the frameworks detector and the module executor each defined their own 5 MB body cap and ran the same io.ReadAll(io.LimitReader(...)) read. move the cap and the read into httpx.MaxBodySize / httpx.ReadCappedBody so both scanners share one ceiling instead of two consts that can drift. no behavior change: the cap value and read semantics are unchanged.
49 lines
2.0 KiB
Go
49 lines
2.0 KiB
Go
/*
|
|
·━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━·
|
|
: :
|
|
: █▀ █ █▀▀ · Blazing-fast pentesting suite :
|
|
: ▄█ █ █▀ · BSD 3-Clause License :
|
|
: :
|
|
: (c) 2022-2026 vmfunc, xyzeva, :
|
|
: lunchcat alumni & contributors :
|
|
: :
|
|
·━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━·
|
|
*/
|
|
|
|
package sifpath
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestUserSubdirLayout(t *testing.T) {
|
|
got, err := UserSubdir("modules")
|
|
if err != nil {
|
|
t.Fatalf("UserSubdir returned error: %v", err)
|
|
}
|
|
if !filepath.IsAbs(got) {
|
|
t.Errorf("UserSubdir(%q) = %q, want an absolute path", "modules", got)
|
|
}
|
|
if base := filepath.Base(got); base != "modules" {
|
|
t.Errorf("UserSubdir(%q) base = %q, want %q", "modules", base, "modules")
|
|
}
|
|
if parent := filepath.Base(filepath.Dir(got)); parent != "sif" {
|
|
t.Errorf("UserSubdir(%q) parent = %q, want %q", "modules", parent, "sif")
|
|
}
|
|
}
|
|
|
|
func TestUserSubdirSiblings(t *testing.T) {
|
|
mods, err := UserSubdir("modules")
|
|
if err != nil {
|
|
t.Fatalf("UserSubdir(modules): %v", err)
|
|
}
|
|
sigs, err := UserSubdir("signatures")
|
|
if err != nil {
|
|
t.Fatalf("UserSubdir(signatures): %v", err)
|
|
}
|
|
if filepath.Dir(mods) != filepath.Dir(sigs) {
|
|
t.Errorf("modules dir %q and signatures dir %q should share a parent", mods, sigs)
|
|
}
|
|
}
|