-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cda96f2
commit 5331d25
Showing
8 changed files
with
135 additions
and
27 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 |
---|---|---|
@@ -1,15 +1,17 @@ | ||
package tgen | ||
|
||
import "github.com/dmdhrumilmistry/fasthttpclient/client" | ||
import ( | ||
"github.com/dmdhrumilmistry/fasthttpclient/client" | ||
) | ||
|
||
// Holds data related for API testing | ||
type ApiTests struct { | ||
type ApiTest struct { | ||
// Fields to be populated before making HTTP request | ||
TestName string | ||
Request *client.Request | ||
TestName string `json:"test_name"` | ||
Request *client.Request `json:"request"` | ||
|
||
// Fields to be populated after making HTTP request | ||
IsVulnerable bool | ||
IsDataLeak bool | ||
Response *client.Response | ||
IsVulnerable bool `json:"is_vulnerable"` | ||
IsDataLeak bool `json:"is_data_leak"` | ||
Response *client.ConcurrentResponse `json:"response"` | ||
} |
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,37 @@ | ||
package utils | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
func CreateDir(dirPath string) error { | ||
if _, err := os.Stat(dirPath); os.IsNotExist(err) { | ||
// Directory does not exist, so create it | ||
err := os.Mkdir(dirPath, 0755) // 0755 is the Unix permission mode | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func WriteFile(filePath string, data []byte) error { | ||
dirPath := filepath.Dir(filePath) | ||
if err := CreateDir(dirPath); err != nil { | ||
return err | ||
} | ||
|
||
file, err := os.OpenFile(filePath, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644) | ||
if err != nil { | ||
return err | ||
} | ||
defer file.Close() | ||
|
||
if _, err := file.Write(data); err != nil { | ||
return err | ||
} | ||
|
||
return 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package report | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/OWASP/OFFAT/src/pkg/tgen" | ||
) | ||
|
||
const JSON = "json" | ||
|
||
func Report(apiTests []*tgen.ApiTest, contentType string) ([]byte, error) { | ||
switch contentType { | ||
case JSON: | ||
return json.Marshal(&apiTests) | ||
default: | ||
return nil, fmt.Errorf("invalid report content type") | ||
} | ||
} |