ruleset_v2 integration test working

This commit is contained in:
Kevin Pham
2023-12-05 15:02:18 -06:00
parent e6e8b0edff
commit 52d12dd1ac
8 changed files with 271 additions and 285 deletions

View File

@@ -1,9 +1,11 @@
package handlers
import (
"fmt"
"ladder/proxychain"
rx "ladder/proxychain/requestmodifiers"
tx "ladder/proxychain/responsemodifiers"
"ladder/proxychain/ruleset"
"github.com/gofiber/fiber/v2"
)
@@ -24,6 +26,10 @@ func NewProxySiteHandler(opts *ProxyOptions) fiber.Handler {
rs = r
}
*/
rs, err := ruleset_v2.NewRuleset("ruleset_v2.yaml")
if err != nil {
panic(err)
}
return func(c *fiber.Ctx) error {
proxychain := proxychain.
@@ -51,9 +57,20 @@ func NewProxySiteHandler(opts *ProxyOptions) fiber.Handler {
tx.PatchDynamicResourceURLs(),
tx.BlockElementRemoval(".article-content"),
// tx.SetContentSecurityPolicy("default-src * 'unsafe-inline' 'unsafe-eval' data: blob:;"),
).
Execute()
)
return proxychain
// load ruleset
rule, exists := rs.GetRule(proxychain.Request.URL)
fmt.Println("============")
fmt.Println(proxychain.Request.URL)
fmt.Println(rs)
fmt.Println("============")
if exists {
fmt.Println("===========EXISTS=")
proxychain.AddOnceRequestModifications(rule.RequestModifications...)
proxychain.AddOnceResponseModifications(rule.ResponseModifications...)
}
return proxychain.Execute()
}
}