Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
dwisiswant0 committed Apr 1, 2021
2 parents 9e52eff + ecac2bd commit e47b21f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

All notable changes to this project should be documented in this file.

### v1.2.2

- Add utility for get datasets
- Remove debug print

### v1.2.1

- Fix exclude threats logic to set datasets
- Fix linter

### v1.1.1

- Add interrupt handler
Expand Down
18 changes: 1 addition & 17 deletions pkg/teler/teler.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package teler

import (
"fmt"
"net/url"
"reflect"
"regexp"
Expand All @@ -13,7 +12,6 @@ import (
"ktbs.dev/teler/common"
"ktbs.dev/teler/pkg/matchers"
"ktbs.dev/teler/pkg/metrics"
"ktbs.dev/teler/resource"
)

// Analyze logs from threat resources
Expand All @@ -28,20 +26,7 @@ func Analyze(options *common.Options, logs *gonx.Entry) (bool, map[string]string
}

if len(datasets) == 0 {
datasets = make(map[string]map[string]string)
rsc := resource.Get()
for i := 0; i < len(rsc.Threat); i++ {
threat := reflect.ValueOf(&rsc.Threat[i]).Elem()
cat := threat.FieldByName("Category").String()
con := threat.FieldByName("Content").String()

if threat.FieldByName("Exclude").Bool() {
continue
}

datasets[cat] = map[string]string{}
datasets[cat]["content"] = con
}
getDatasets()
}

for cat, data := range datasets {
Expand Down Expand Up @@ -217,7 +202,6 @@ func Analyze(options *common.Options, logs *gonx.Entry) (bool, map[string]string
refs := strings.Split(data["content"], "\n")

match = matchers.IsMatchFuzz(req.Host, refs)
fmt.Println(match)
if match {
metrics.GetBadReferrer.WithLabelValues(log["http_referer"]).Inc()
}
Expand Down
24 changes: 24 additions & 0 deletions pkg/teler/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package teler

import (
"reflect"

"ktbs.dev/teler/resource"
)

func getDatasets() {
datasets = make(map[string]map[string]string)
rsc := resource.Get()
for i := 0; i < len(rsc.Threat); i++ {
threat := reflect.ValueOf(&rsc.Threat[i]).Elem()
cat := threat.FieldByName("Category").String()
con := threat.FieldByName("Content").String()

if threat.FieldByName("Exclude").Bool() {
continue
}

datasets[cat] = map[string]string{}
datasets[cat]["content"] = con
}
}

0 comments on commit e47b21f

Please sign in to comment.