diff --git a/.gitignore b/.gitignore
index 071f5bf..e32954c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,7 @@ test/
main
test
+
+nohup.out
+repos/
+x-patrol
diff --git a/conf/app.ini b/conf/app.ini
index da3c419..20c84dd 100644
--- a/conf/app.ini
+++ b/conf/app.ini
@@ -15,3 +15,6 @@ USER = xsec
PASSWD = x@xsec.io
SSL_MODE = disable
PATH = data
+
+[search]
+MONTHS = 2
diff --git a/tasks/tasks.go b/tasks/tasks.go
index 0fc5d3c..ae22296 100644
--- a/tasks/tasks.go
+++ b/tasks/tasks.go
@@ -163,7 +163,7 @@ func DoSearch(reposConfig []models.RepoConfig, rules models.Rules) (map[string]*
} else {
// when rules.Part in ("filename", "path", "extension"), only search filename, and set rules.Pattern = "\\."
opts.FileRegexp = rules.Pattern
- rules.Pattern = "\\."
+ rules.Pattern = "."
}
var filesOpened int
diff --git a/templates/rules_edit.html b/templates/rules_edit.html
index e308976..9f73dff 100755
--- a/templates/rules_edit.html
+++ b/templates/rules_edit.html
@@ -95,8 +95,9 @@
@@ -127,9 +128,7 @@
-
+
@@ -157,6 +156,24 @@
+
+
diff --git a/util/githubsearch/gitclient.go b/util/githubsearch/gitclient.go
index c81a60e..15327ef 100644
--- a/util/githubsearch/gitclient.go
+++ b/util/githubsearch/gitclient.go
@@ -26,6 +26,7 @@ package githubsearch
import (
"x-patrol/models"
+ "x-patrol/settings"
"github.com/google/go-github/github"
@@ -134,6 +135,11 @@ func (c *Client) SearchCode(keyword string) ([]*github.CodeSearchResult, error)
var allSearchResult []*github.CodeSearchResult
var err error
+ cfg := settings.Cfg
+ sec := cfg.Section("search")
+ months := sec.Key("MONTHS").MustInt(2)
+ logger.Log.Infof("months: %v", months)
+
ctx := context.Background()
listOpt := github.ListOptions{PerPage: 100}
opt := &github.SearchOptions{Sort: "indexed", Order: "desc", TextMatch: true, ListOptions: listOpt}
@@ -147,9 +153,11 @@ func (c *Client) SearchCode(keyword string) ([]*github.CodeSearchResult, error)
repo, _, _ := c.Client.Repositories.GetByID(ctx, id)
pushTime := repo.GetPushedAt().Time
now := time.Now()
- if now.Sub(pushTime).Hours()/24 <= 60 {
+ if now.Sub(pushTime).Hours()/24/30 <= float64(months) {
logger.Log.Infof("repo: %v, pushed Time: %v, keyword: %v", repo.GetFullName(), pushTime, keyword)
t = append(t, codeResult)
+ } else {
+ logger.Log.Infof("expired ==> repo: %v, pushed Time: %v, keyword: %v", repo.GetFullName(), pushTime, keyword)
}
}