-
-
Notifications
You must be signed in to change notification settings - Fork 620
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add a tool to generate the TLS configuration form Mozilla's ciphers recommendation (#178) * Add a tool which generates the TLS rule configuration from Mozilla server side TLS configuration * Update README * Remove trailing space in README * Update dependencies * Fix the commends of the generated functions * Add nil pointer check to rule. (#181) TypeOf returns the type of expression e, or nil if not found. We are calling .String() on a value that may be nil in this clause. Relates to #174 * Add support for YAML output format (#177) * Add YAML output format * Update README * added rule to check for tainted file path * added #nosec to main/issue.go * updated test case import
- Loading branch information
Showing
7 changed files
with
100 additions
and
0 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
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,49 @@ | ||
// (c) Copyright 2016 Hewlett Packard Enterprise Development LP | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package rules | ||
|
||
import ( | ||
"go/ast" | ||
"go/types" | ||
|
||
"github.com/GoASTScanner/gas" | ||
) | ||
|
||
type readfile struct { | ||
gas.CallList | ||
} | ||
|
||
// Match inspects AST nodes to determine if the match the methods `os.Open` or `ioutil.ReadFile` | ||
func (r *readfile) Match(n ast.Node, c *gas.Context) (*gas.Issue, error) { | ||
if node := r.ContainsCallExpr(n, c); node != nil { | ||
for _, arg := range node.Args { | ||
if ident, ok := arg.(*ast.Ident); ok { | ||
obj := c.Info.ObjectOf(ident) | ||
if _, ok := obj.(*types.Var); ok && !gas.TryResolve(ident, c) { | ||
return gas.NewIssue(c, n, "File inclusion launched with variable", gas.Medium, gas.High), nil | ||
} | ||
} | ||
} | ||
} | ||
return nil, nil | ||
} | ||
|
||
// NewReadFile detects cases where we read files | ||
func NewReadFile(conf gas.Config) (gas.Rule, []ast.Node) { | ||
rule := &readfile{gas.NewCallList()} | ||
rule.Add("io/ioutil", "ReadFile") | ||
rule.Add("os", "Open") | ||
return rule, []ast.Node{(*ast.CallExpr)(nil)} | ||
} |
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