File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 "github.com/ptaas-tool/base-api/internal/config/ftp"
99 "github.com/ptaas-tool/base-api/internal/config/migration"
1010 "github.com/ptaas-tool/base-api/internal/config/scanner"
11+ "github.com/ptaas-tool/base-api/internal/core/ai"
1112 "github.com/ptaas-tool/base-api/internal/storage/sql"
1213
1314 "github.com/knadh/koanf"
@@ -23,6 +24,7 @@ type Config struct {
2324 Migrate migration.Config `koanf:"migrate"`
2425 Scanner scanner.Config `koanf:"scanner"`
2526 FTP ftp.Config `koanf:"ftp"`
27+ AI ai.Config `koanf:"ai"`
2628}
2729
2830func Load (path string ) Config {
Original file line number Diff line number Diff line change 55 "github.com/ptaas-tool/base-api/internal/config/ftp"
66 "github.com/ptaas-tool/base-api/internal/config/migration"
77 "github.com/ptaas-tool/base-api/internal/config/scanner"
8+ "github.com/ptaas-tool/base-api/internal/core/ai"
89 "github.com/ptaas-tool/base-api/internal/storage/sql"
910)
1011
@@ -34,5 +35,11 @@ func Default() Config {
3435 Secret : "" ,
3536 Access : "" ,
3637 },
38+ AI : ai.Config {
39+ Enable : true ,
40+ Method : "random" ,
41+ Limit : 10 ,
42+ Factor : 7 ,
43+ },
3744 }
3845}
Original file line number Diff line number Diff line change @@ -2,21 +2,27 @@ package ai
22
33import "math/rand"
44
5- type AI struct {}
5+ type AI struct {
6+ Cfg Config
7+ }
68
79func (a AI ) GetAttacks (list , vulnerabilities []string ) []string {
810 records := make ([]string , 0 )
911
10- // logic goes here (now it's random)
11- for _ , item := range list {
12- if item == "injection" || item == "payload" {
13- records = append (records , item )
14-
15- continue
16- }
12+ if ! a .Cfg .Enable {
13+ return list
14+ }
1715
18- if rand .Intn (10 ) > 8 {
19- records = append (records , item )
16+ switch a .Cfg .Method {
17+ case "svm" :
18+ break
19+ case "nbias" :
20+ break
21+ default :
22+ for _ , item := range list {
23+ if rand .Intn (a .Cfg .Limit ) > a .Cfg .Factor {
24+ records = append (records , item )
25+ }
2026 }
2127 }
2228
Original file line number Diff line number Diff line change 1+ package ai
2+
3+ type Config struct {
4+ Method string `koanf:"method"`
5+ Factor int `koanf:"factor"`
6+ Limit int `koanf:"limit"`
7+ Enable bool `koanf:"enable"`
8+ }
You can’t perform that action at this time.
0 commit comments