-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: make engine pluggable (#1615)
- Loading branch information
Showing
1,750 changed files
with
3,242 additions
and
2,964 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
internal/parser/sitter/**/*.c linguist-generated | ||
internal/parser/sitter/**/*.cc linguist-generated | ||
pkg/parser/sitter/**/*.c linguist-generated | ||
pkg/parser/sitter/**/*.cc linguist-generated |
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 |
---|---|---|
|
@@ -24,4 +24,4 @@ jobs: | |
with: | ||
go-version: 1.21 | ||
- name: Run package tests | ||
run: go test -v ./internal/... | ||
run: go test -v ./pkg/... |
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 |
---|---|---|
@@ -1,16 +1,10 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/bearer/bearer/cmd/bearer/build" | ||
"github.com/bearer/bearer/internal/commands" | ||
"github.com/bearer/bearer/external/run" | ||
) | ||
|
||
func main() { | ||
app := commands.NewApp(build.Version, build.CommitSHA) | ||
if err := app.Execute(); err != nil { | ||
// error messages are printed by the framework | ||
os.Exit(1) | ||
} | ||
run.Run(build.Version, build.CommitSHA, run.NewEngine(run.DefaultLanguages())) | ||
} |
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
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
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,97 @@ | ||
package run | ||
|
||
import ( | ||
"os" | ||
"regexp" | ||
|
||
"github.com/bearer/bearer/pkg/classification/schema" | ||
"github.com/bearer/bearer/pkg/commands" | ||
"github.com/bearer/bearer/pkg/engine" | ||
"github.com/bearer/bearer/pkg/engine/implementation" | ||
"github.com/bearer/bearer/pkg/languages" | ||
"github.com/bearer/bearer/pkg/scanner/ast/query" | ||
"github.com/bearer/bearer/pkg/scanner/ast/tree" | ||
"github.com/bearer/bearer/pkg/scanner/detectors/common" | ||
"github.com/bearer/bearer/pkg/scanner/detectors/types" | ||
"github.com/bearer/bearer/pkg/scanner/language" | ||
"github.com/bearer/bearer/pkg/scanner/ruleset" | ||
"github.com/bearer/bearer/pkg/util/regex" | ||
"github.com/bearer/bearer/pkg/util/stringutil" | ||
) | ||
|
||
type Object = common.Object | ||
type Property = common.Property | ||
type String = common.String | ||
|
||
type Engine = engine.Engine | ||
|
||
type Analyzer = language.Analyzer | ||
type Language = language.Language | ||
type Pattern = language.Pattern | ||
type PatternBase = language.PatternBase | ||
type PatternVariable = language.PatternVariable | ||
type Scope = language.Scope | ||
|
||
type Query = query.Query | ||
type Set = query.Set | ||
|
||
type Rule = ruleset.Rule | ||
|
||
type Classifier = schema.Classifier | ||
|
||
type Builder = tree.Builder | ||
type Node = tree.Node | ||
|
||
type Context = types.Context | ||
type Detection = types.Detection | ||
type Detector = types.Detector | ||
type DetectorBase = types.DetectorBase | ||
|
||
var BuiltinObjectRule = ruleset.BuiltinObjectRule | ||
var BuiltinStringRule = ruleset.BuiltinStringRule | ||
|
||
func GetNonVirtualObjects(detectorContext types.Context, node *tree.Node) ([]*types.Detection, error) { | ||
return common.GetNonVirtualObjects(detectorContext, node) | ||
} | ||
|
||
func StripQuotes(input string) string { | ||
return stringutil.StripQuotes(input) | ||
} | ||
|
||
func ConcatenateChildStrings(node *tree.Node, detectorContext types.Context) ([]interface{}, error) { | ||
return common.ConcatenateChildStrings(node, detectorContext) | ||
} | ||
|
||
func ConcatenateAssignEquals(node *tree.Node, detectorContext types.Context) ([]interface{}, error) { | ||
return common.ConcatenateAssignEquals(node, detectorContext) | ||
} | ||
|
||
func ProjectObject(node *tree.Node, detectorContext types.Context, objectNode *tree.Node, objectName string, propertyName string, isPropertyAccess bool) ([]interface{}, error) { | ||
return common.ProjectObject(node, detectorContext, objectNode, objectName, propertyName, isPropertyAccess) | ||
} | ||
|
||
func ReplaceAllWithSubmatches(pattern *regexp.Regexp, input string, replace func(submatches []string) (string, error)) (string, error) { | ||
return regex.ReplaceAllWithSubmatches(pattern, input, replace) | ||
} | ||
|
||
func NewScope(parent *language.Scope) *language.Scope { | ||
return language.NewScope(parent) | ||
} | ||
|
||
func NewEngine(languages []Language) Engine { | ||
return implementation.New(languages) | ||
} | ||
|
||
func DefaultLanguages() []Language { | ||
return languages.Default() | ||
} | ||
|
||
func Run(version, commitSHA string, engine Engine) { | ||
err := commands.NewApp(version, commitSHA, engine).Execute() | ||
engine.Close() | ||
|
||
if err != nil { | ||
// error messages are printed by the framework | ||
os.Exit(1) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.