Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
qiuqunfeng
waf-console
Commits
6ad35326
Commit
6ad35326
authored
Mar 29, 2025
by
qiuqunfeng
Browse files
Merge branch 'dev' of
https://scm.tensorsecurity.cn/qiuqunfeng/waf-console
into dev
parents
3989b6ea
f17ae858
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
15 deletions
+7
-15
internal/controller/waf.go
internal/controller/waf.go
+1
-0
internal/service/log_consumer.go
internal/service/log_consumer.go
+2
-10
internal/service/types.go
internal/service/types.go
+1
-1
internal/service/waf.go
internal/service/waf.go
+3
-4
No files found.
internal/controller/waf.go
View file @
6ad35326
...
...
@@ -506,6 +506,7 @@ func (c *WafController) ListListenerHistory(ctx *gin.Context) {
utils
.
AssembleResponse
(
ctx
,
nil
,
err
)
return
}
limit
=
1000000
name
:=
ctx
.
Query
(
"name"
)
gatewayName
:=
ctx
.
Query
(
"gateway_name"
)
listenerName
:=
ctx
.
Query
(
"listener_name"
)
...
...
internal/service/log_consumer.go
View file @
6ad35326
...
...
@@ -164,17 +164,9 @@ func (s *LogConsumerService) Handle(ctx context.Context, message []byte) error {
s
.
esStore
.
Save
(
ctx
,
bulkableRequests
)
wafService
:=
model
.
WafService
{}
err
=
s
.
db
.
WithContext
(
ctx
)
.
Where
(
"id = ?"
,
WafDetectionMessage
.
ServiceID
)
.
First
(
&
wafService
)
.
Error
err
=
s
.
db
.
WithContext
(
ctx
)
.
Model
(
&
model
.
WafService
{})
.
Where
(
"id = ?"
,
WafDetectionMessage
.
ServiceID
)
.
Update
(
"attack_num"
,
gorm
.
Expr
(
"attack_num + ?"
,
1
))
.
Error
if
err
!=
nil
{
log
.
Err
(
err
)
.
Int64
(
"WafDetectionMessage.ServiceID"
,
WafDetectionMessage
.
ServiceID
)
.
Msg
(
"Find waf_service fails"
)
return
err
}
attackNumber
:=
int
(
wafService
.
AttackNum
)
+
unPassCount
err
=
s
.
db
.
WithContext
(
ctx
)
.
Model
(
&
model
.
WafService
{})
.
Where
(
"id = ?"
,
WafDetectionMessage
.
ServiceID
)
.
Update
(
"attack_number"
,
attackNumber
)
.
Error
if
err
!=
nil
{
log
.
Err
(
err
)
.
Int64
(
"WafDetectionMessage.ServiceID"
,
WafDetectionMessage
.
ServiceID
)
.
Int
(
"attack_number"
,
attackNumber
)
.
Msg
(
"update waf_service attack_number fails"
)
log
.
Err
(
err
)
.
Int64
(
"WafDetectionMessage.ServiceID"
,
WafDetectionMessage
.
ServiceID
)
.
Msg
(
"update waf_service attack_number fails"
)
return
err
}
...
...
internal/service/types.go
View file @
6ad35326
...
...
@@ -349,7 +349,7 @@ type AttackLogFilter struct {
AttackUrl
string
`json:"attack_url"`
AttackIp
string
`json:"attack_ip"`
AttackType
string
`json:"attack_type"`
AttackApp
string
`json:"attack_app"`
AttackApp
string
`json:"attack_app"`
// gateway name
AttackListener
string
`json:"attack_listener"`
Action
string
`json:"action"`
Token
string
`json:"token"`
...
...
internal/service/waf.go
View file @
6ad35326
...
...
@@ -250,7 +250,7 @@ func (s *wafService) CreateWaf(ctx context.Context, req *CreateWafReq) (*WafServ
Port
:
req
.
Port
,
Workload
:
v1alpha1
.
WorkloadRef
{
Kind
:
req
.
GatewayName
,
Name
:
req
.
Listener
Name
,
Name
:
req
.
Gateway
Name
,
Namespace
:
req
.
Namespace
,
ClusterKey
:
req
.
RegionCode
,
},
...
...
@@ -841,7 +841,7 @@ func (s *wafService) ListAttackLogs(ctx context.Context, req *AttackLogFilter) (
boolQuery
.
Filter
(
elastic
.
NewMatchPhraseQuery
(
"attack_ip"
,
req
.
AttackIp
)
.
Slop
(
0
))
}
if
req
.
AttackApp
!=
""
{
boolQuery
.
Filter
(
elastic
.
NewMatchPhraseQuery
(
"
attacked_app
"
,
req
.
AttackApp
)
.
Slop
(
0
))
boolQuery
.
Filter
(
elastic
.
NewMatchPhraseQuery
(
"
res_name
"
,
req
.
AttackApp
)
.
Slop
(
0
))
}
if
req
.
AttackType
!=
""
{
attackTypes
:=
strings
.
Split
(
req
.
AttackType
,
","
)
...
...
@@ -921,8 +921,7 @@ func (s *wafService) ListAttackLogs(ctx context.Context, req *AttackLogFilter) (
Uuid
:
wafDetection
.
ID
,
AttackTime
:
wafDetection
.
AttackTime
,
AttackIp
:
wafDetection
.
AttackIP
,
AttackedApp
:
wafDetection
.
AttackedApp
,
AttackListener
:
wafDetection
.
ResName
,
AttackListener
:
wafDetection
.
AttackedApp
,
AttackType
:
wafDetection
.
AttackType
,
Action
:
wafDetection
.
Action
,
ClusterKey
:
wafDetection
.
ClusterKey
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment