Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
0x19 committed Aug 15, 2023
1 parent 21e5b61 commit f589240
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
12 changes: 8 additions & 4 deletions audit/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ import (

// allowedArgs defines a list of allowed arguments for slither.
var allowedArgs = map[string]bool{
"--json": true,
"-": true,
"--codex": true,
"--json": true,
"-": true,
"--codex": true,
"--solc-disable-warnings": true,
"--ignore-compile": true,
"--fail-none": true,
"--buidler-ignore-compile": true,
}

// requiredArgs defines a list of required arguments for slither.
Expand All @@ -34,7 +38,7 @@ func NewDefaultConfig(tempDir string) (*Config, error) {
toReturn := &Config{
tempDir: tempDir,
Arguments: []string{
"--json", "-", // Output to stdout.
"--ignore-compile", "--buidler-ignore-compile", "--fail-none", "--solc-disable-warnings", "--json", "-", // Output to stdout.
},
}

Expand Down
9 changes: 1 addition & 8 deletions sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ func (s *Sources) WriteToDir(path string) error {
// Write each SourceUnit's content to a file in the specified directory
for _, sourceUnit := range s.SourceUnits {
content := simplifyImportPaths(sourceUnit.Content)

filePath := filepath.Join(path, sourceUnit.Name+".sol")
if err := utils.WriteToFile(filePath, []byte(content)); err != nil {
return fmt.Errorf("failed to write source unit %s to file: %v", sourceUnit.Name, err)
Expand Down Expand Up @@ -403,17 +404,13 @@ func (s *Sources) SortContracts() error {
for _, sourceUnit := range s.SourceUnits {
imports := extractImports(sourceUnit.Content)
var dependencies []string
//fmt.Println("Unit name ->", sourceUnit.Name)
for _, imp := range imports {
baseName := filepath.Base(imp)
//fmt.Println("Unit name ->", sourceUnit.Name, "Basename -> ", baseName, "Contract Name ->", strings.TrimSuffix(baseName, ".sol"))
dependencies = append(dependencies, strings.TrimSuffix(baseName, ".sol"))
}
nodes = append(nodes, Node{Name: sourceUnit.Name, Dependencies: dependencies})
}

//spew.Dump(nodes)

sortedNames, err := topologicalSort(nodes)
if err != nil {
return err
Expand All @@ -426,10 +423,6 @@ func (s *Sources) SortContracts() error {
}
}

//for _, unit := range sortedSourceUnits {
// fmt.Println(unit.Name)
//}

s.SourceUnits = sortedSourceUnits
return nil
}
Expand Down

0 comments on commit f589240

Please sign in to comment.