This repository has been archived by the owner on Feb 13, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #189 from kitabisa/development
Prep v2 (Beta)
- Loading branch information
Showing
31 changed files
with
712 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ on: | |
- master | ||
- development | ||
pull_request: | ||
branches-ignore: | ||
- dependabot/** | ||
|
||
jobs: | ||
checks: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
name: Review | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- development | ||
- master | ||
- development | ||
|
||
jobs: | ||
review: | ||
name: Code Review | ||
runs-on: ubuntu-latest | ||
runs-on: ubuntu-latest | ||
if: startsWith(github.head_ref, 'dependabot/') == false | ||
steps: | ||
- name: Check out code | ||
uses: actions/[email protected] | ||
|
@@ -16,4 +21,15 @@ jobs: | |
uses: kitabisa/sonarqube-action@development | ||
with: | ||
host: ${{ secrets.SONARQUBE_HOST }} | ||
login: ${{ secrets.SONARQUBE_TOKEN }} | ||
login: ${{ secrets.SONARQUBE_TOKEN }} | ||
|
||
- name: Run Semgrep | ||
uses: returntocorp/semgrep-action@v1 | ||
with: | ||
config: | | ||
p/ci | ||
p/owasp-top-ten | ||
p/golang | ||
p/command-injection | ||
p/security-audit | ||
p/secrets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package runner | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
|
||
"ktbs.dev/teler/common" | ||
"ktbs.dev/teler/pkg/errors" | ||
"ktbs.dev/teler/pkg/logs" | ||
) | ||
|
||
func log(options *common.Options, data map[string]string) { | ||
m := options.Configs.Logs | ||
v := reflect.ValueOf(m) | ||
t := v.Type() | ||
|
||
for i := 0; i < v.NumField(); i++ { | ||
if v.Field(i).FieldByName("Active").Bool() { | ||
switch t.Field(i).Name { | ||
case "File": | ||
toFile(options, data) | ||
case "Zinc": | ||
toZinc(options, data) | ||
} | ||
} | ||
} | ||
} | ||
|
||
func toFile(options *common.Options, data map[string]string) { | ||
err := logs.File(options, data) | ||
if err != nil { | ||
errors.Show(err.Error()) | ||
} | ||
} | ||
|
||
func toZinc(options *common.Options, data map[string]string) { | ||
zinc := options.Configs.Logs.Zinc | ||
base := "http" | ||
if zinc.SSL { | ||
base += "s" | ||
} | ||
base += fmt.Sprint("://", zinc.Host, ":", zinc.Port) | ||
|
||
err := logs.Zinc(base, zinc.Index, zinc.Base64Auth, data) | ||
if err != nil { | ||
errors.Show(err.Error()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package runner | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"reflect" | ||
"strconv" | ||
|
||
"github.com/projectdiscovery/gologger" | ||
"github.com/prometheus/client_golang/prometheus/promhttp" | ||
"ktbs.dev/teler/common" | ||
"ktbs.dev/teler/pkg/errors" | ||
"ktbs.dev/teler/pkg/metrics" | ||
) | ||
|
||
func metric(options *common.Options) { | ||
m := options.Configs.Metrics | ||
v := reflect.ValueOf(m) | ||
t := v.Type() | ||
|
||
for i := 0; i < v.NumField(); i++ { | ||
if v.Field(i).FieldByName("Active").Bool() { | ||
switch t.Field(i).Name { | ||
case "Prometheus": | ||
startPrometheus(options) | ||
} | ||
} | ||
} | ||
} | ||
|
||
func startPrometheus(options *common.Options) { | ||
p := options.Configs.Metrics.Prometheus | ||
|
||
if p.Host == "" { | ||
p.Host = "127.0.0.1" | ||
} | ||
|
||
if p.Port == 0 { | ||
p.Port = 9090 | ||
} | ||
|
||
if p.Endpoint == "" { | ||
p.Endpoint = "/metrics" | ||
} | ||
|
||
s := fmt.Sprint(p.Host, ":", strconv.Itoa(p.Port)) | ||
e := p.Endpoint | ||
|
||
go func() { | ||
http.Handle(e, promhttp.Handler()) | ||
|
||
err := http.ListenAndServe(s, nil) // nosemgrep: go.lang.security.audit.net.use-tls.use-tls | ||
if err != nil { | ||
errors.Exit(err.Error()) | ||
} | ||
}() | ||
|
||
metrics.Prometheus() | ||
gologger.Info().Msgf(fmt.Sprint("Listening metrics on http://", s, e)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package runner | ||
|
||
import "regexp" | ||
|
||
func removeLBR(s string) string { | ||
re := regexp.MustCompile(`\x{000D}\x{000A}|[\x{000A}\x{000B}\x{000C}\x{000D}\x{0085}\x{2028}\x{2029}]`) | ||
return re.ReplaceAllString(s, ``) | ||
} |
Oops, something went wrong.