WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 9390ca4

Browse files
committed
use bufio.Scanner for memory efficiency
1 parent aa31958 commit 9390ca4

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

rules/trojansource.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,38 @@ func (r *trojanSource) Match(node ast.Node, c *gosec.Context) (*issue.Issue, err
3939
return nil, nil
4040
}
4141

42+
// func (r *trojanSource) Match(node ast.Node, c *gosec.Context) (*issue.Issue, error) {
43+
// if file, ok := node.(*ast.File); ok {
44+
// fobj := c.FileSet.File(file.Pos())
45+
// if fobj == nil {
46+
// return nil, nil
47+
// }
48+
49+
// file, err := os.Open(fobj.Name())
50+
// if err != nil {
51+
// log.Fatal(err)
52+
// }
53+
54+
// defer file.Close()
55+
56+
// scanner := bufio.NewScanner(file)
57+
// for scanner.Scan() {
58+
// line := scanner.Text()
59+
// for _, ch := range line {
60+
// if _, exists := r.bidiChars[ch]; exists {
61+
// return c.NewIssue(node, r.ID(), r.What, r.Severity, r.Confidence), nil
62+
// }
63+
// }
64+
// }
65+
66+
// if err := scanner.Err(); err != nil {
67+
// log.Fatal(err)
68+
// }
69+
// }
70+
71+
// return nil, nil
72+
// }
73+
4274
func NewTrojanSource(id string, _ gosec.Config) (gosec.Rule, []ast.Node) {
4375
return &trojanSource{
4476
MetaData: issue.MetaData{

0 commit comments

Comments
 (0)