mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-11 19:18:46 +00:00
Compare commits
3 Commits
Xe/ci-mult
...
Xe/doc-dis
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ef36a4f65 | ||
|
|
b5dadc0ad5 | ||
|
|
d827530118 |
1
.github/actions/spelling/expect.txt
vendored
1
.github/actions/spelling/expect.txt
vendored
@@ -253,7 +253,6 @@ oci
|
|||||||
OCOB
|
OCOB
|
||||||
ogtag
|
ogtag
|
||||||
oklch
|
oklch
|
||||||
oldstable
|
|
||||||
omgili
|
omgili
|
||||||
omgilibot
|
omgilibot
|
||||||
openai
|
openai
|
||||||
|
|||||||
12
.github/workflows/go.yml
vendored
12
.github/workflows/go.yml
vendored
@@ -12,11 +12,6 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
go_tests:
|
go_tests:
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
go_version:
|
|
||||||
- oldstable
|
|
||||||
- stable
|
|
||||||
#runs-on: alrest-techarohq
|
#runs-on: alrest-techarohq
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
@@ -31,11 +26,10 @@ jobs:
|
|||||||
|
|
||||||
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||||
with:
|
with:
|
||||||
node-version: "latest"
|
node-version: "24.11.0"
|
||||||
|
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
|
||||||
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
|
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go_version }}
|
go-version: "stable"
|
||||||
|
|
||||||
- name: Cache playwright binaries
|
- name: Cache playwright binaries
|
||||||
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
|
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Fixed mixed tab/space indentation in Caddy documentation code block
|
- Fixed mixed tab/space indentation in Caddy documentation code block
|
||||||
|
|
||||||
<!-- This changes the project to: -->
|
<!-- This changes the project to: -->
|
||||||
- Fix CEL internal errors when iterating `headers`/`query` map wrappers by implementing map iterators for `HTTPHeaders` and `URLValues` ([#1465](https://github.com/TecharoHQ/anubis/pull/1465)).
|
|
||||||
|
|
||||||
## v1.25.0: Necron
|
## v1.25.0: Necron
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"anubis_compromise": "Anubisは妥協策です。AnubisはHashcashのようなProof-of-Work方式を採用しており、これは元々メールスパムを減らすために提案された仕組みです。個人レベルでは追加の負荷は無視できる程度ですが、大規模なスクレイピングでは負荷が積み重なり、スクレイピングのコストが大幅に増加します。",
|
"anubis_compromise": "Anubisは妥協策です。AnubisはHashcashのようなProof-of-Work方式を採用しており、これは元々メールスパムを減らすために提案された仕組みです。個人レベルでは追加の負荷は無視できる程度ですが、大規模なスクレイピングでは負荷が積み重なり、スクレイピングのコストが大幅に増加します。",
|
||||||
"hack_purpose": "最終的に、これはヘッドレスブラウザのフィンガープリントと識別に時間を費やすためのプレースホルダーソリューションです(例:フォントレンダリングの方法による)。これにより、正当なユーザーにはチャレンジのプルーフオブワークページを提示する必要がなくなります。",
|
"hack_purpose": "最終的に、これはヘッドレスブラウザのフィンガープリントと識別に時間を費やすためのプレースホルダーソリューションです(例:フォントレンダリングの方法による)。これにより、正当なユーザーにはチャレンジのプルーフオブワークページを提示する必要がなくなります。",
|
||||||
"jshelter_note": "Anubisは、JShelterのようなプラグインが無効化する最新のJavaScript機能を必要とします。このドメインではJShelterや同様のプラグインを無効にしてください。",
|
"jshelter_note": "Anubisは、JShelterのようなプラグインが無効化する最新のJavaScript機能を必要とします。このドメインではJShelterや同様のプラグインを無効にしてください。",
|
||||||
"version_info": "このウェブサイトはAnubisで動作しています バージョン",
|
"version_info": "このウェブサイトはAnubisバージョンで動作しています",
|
||||||
"try_again": "再試行",
|
"try_again": "再試行",
|
||||||
"go_home": "ホームに戻る",
|
"go_home": "ホームに戻る",
|
||||||
"contact_webmaster": "もしブロックされるべきでないと思われる場合は、ウェブマスターにご連絡ください:",
|
"contact_webmaster": "もしブロックされるべきでないと思われる場合は、ウェブマスターにご連絡ください:",
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
package policy
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/TecharoHQ/anubis/internal/dns"
|
|
||||||
"github.com/TecharoHQ/anubis/lib/config"
|
|
||||||
"github.com/TecharoHQ/anubis/lib/store/memory"
|
|
||||||
)
|
|
||||||
|
|
||||||
func newTestDNS(t *testing.T) *dns.Dns {
|
|
||||||
t.Helper()
|
|
||||||
|
|
||||||
ctx := t.Context()
|
|
||||||
memStore := memory.New(ctx)
|
|
||||||
cache := dns.NewDNSCache(300, 300, memStore)
|
|
||||||
return dns.New(ctx, cache)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCELChecker_MapIterationWrappers(t *testing.T) {
|
|
||||||
cfg := &config.ExpressionOrList{
|
|
||||||
Expression: `headers.exists(k, k == "Accept") && query.exists(k, k == "format")`,
|
|
||||||
}
|
|
||||||
|
|
||||||
checker, err := NewCELChecker(cfg, newTestDNS(t))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("creating CEL checker failed: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodGet, "https://example.com/?format=json", nil)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("making request failed: %v", err)
|
|
||||||
}
|
|
||||||
req.Header.Set("Accept", "application/json")
|
|
||||||
|
|
||||||
got, err := checker.Check(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("checking expression failed: %v", err)
|
|
||||||
}
|
|
||||||
if !got {
|
|
||||||
t.Fatal("expected expression to evaluate true")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -66,9 +66,7 @@ func (h HTTPHeaders) Get(key ref.Val) ref.Val {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h HTTPHeaders) Iterator() traits.Iterator {
|
func (h HTTPHeaders) Iterator() traits.Iterator { panic("TODO(Xe): implement me") }
|
||||||
return newMapIterator(h.Header)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h HTTPHeaders) IsZeroValue() bool {
|
func (h HTTPHeaders) IsZeroValue() bool {
|
||||||
return len(h.Header) == 0
|
return len(h.Header) == 0
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
package expressions
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"maps"
|
|
||||||
"reflect"
|
|
||||||
"slices"
|
|
||||||
|
|
||||||
"github.com/google/cel-go/common/types"
|
|
||||||
"github.com/google/cel-go/common/types/ref"
|
|
||||||
"github.com/google/cel-go/common/types/traits"
|
|
||||||
)
|
|
||||||
|
|
||||||
var ErrNotImplemented = errors.New("expressions: not implemented")
|
|
||||||
|
|
||||||
type stringSliceIterator struct {
|
|
||||||
keys []string
|
|
||||||
idx int
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *stringSliceIterator) Value() any {
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *stringSliceIterator) ConvertToNative(typeDesc reflect.Type) (any, error) {
|
|
||||||
return nil, ErrNotImplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *stringSliceIterator) ConvertToType(typeValue ref.Type) ref.Val {
|
|
||||||
return types.NewErr("can't convert from %q to %q", types.IteratorType, typeValue)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *stringSliceIterator) Equal(other ref.Val) ref.Val {
|
|
||||||
return types.NewErr("can't compare %q to %q", types.IteratorType, other.Type())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *stringSliceIterator) Type() ref.Type {
|
|
||||||
return types.IteratorType
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *stringSliceIterator) HasNext() ref.Val {
|
|
||||||
return types.Bool(s.idx < len(s.keys))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *stringSliceIterator) Next() ref.Val {
|
|
||||||
if s.HasNext() != types.True {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
val := s.keys[s.idx]
|
|
||||||
s.idx++
|
|
||||||
return types.String(val)
|
|
||||||
}
|
|
||||||
|
|
||||||
func newMapIterator(m map[string][]string) traits.Iterator {
|
|
||||||
return &stringSliceIterator{
|
|
||||||
keys: slices.Collect(maps.Keys(m)),
|
|
||||||
idx: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package expressions
|
package expressions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -10,6 +11,8 @@ import (
|
|||||||
"github.com/google/cel-go/common/types/traits"
|
"github.com/google/cel-go/common/types/traits"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var ErrNotImplemented = errors.New("expressions: not implemented")
|
||||||
|
|
||||||
// URLValues is a type wrapper to expose url.Values into CEL programs.
|
// URLValues is a type wrapper to expose url.Values into CEL programs.
|
||||||
type URLValues struct {
|
type URLValues struct {
|
||||||
url.Values
|
url.Values
|
||||||
@@ -66,9 +69,7 @@ func (u URLValues) Get(key ref.Val) ref.Val {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u URLValues) Iterator() traits.Iterator {
|
func (u URLValues) Iterator() traits.Iterator { panic("TODO(Xe): implement me") }
|
||||||
return newMapIterator(u.Values)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u URLValues) IsZeroValue() bool {
|
func (u URLValues) IsZeroValue() bool {
|
||||||
return len(u.Values) == 0
|
return len(u.Values) == 0
|
||||||
|
|||||||
Reference in New Issue
Block a user