mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-27 17:25:27 +00:00
* use parsed options while signing * update project layout to v3 * fix .gitignore * remove example template * misc updates * bump tlsx version * hide template sig warning with env * js: retain value while using log * fix nil pointer derefernce * misc doc update --------- Co-authored-by: sandeep <8293321+ehsandeep@users.noreply.github.com>
38 lines
986 B
Go
38 lines
986 B
Go
package disk
|
|
|
|
import (
|
|
"io"
|
|
"io/fs"
|
|
"os"
|
|
)
|
|
|
|
// DiskCatalog is a template catalog helper implementation based on disk
|
|
type DiskCatalog struct {
|
|
templatesDirectory string
|
|
templatesFS fs.FS // TODO: Refactor to use this
|
|
}
|
|
|
|
// NewCatalog creates a new Catalog structure using provided input items
|
|
// using disk based items
|
|
func NewCatalog(directory string) *DiskCatalog {
|
|
catalog := &DiskCatalog{templatesDirectory: directory}
|
|
if directory != "" {
|
|
catalog.templatesFS = os.DirFS(directory)
|
|
} else {
|
|
catalog.templatesFS = os.DirFS("./")
|
|
}
|
|
return catalog
|
|
}
|
|
|
|
// OpenFile opens a file and returns an io.ReadCloser to the file.
|
|
// It is used to read template and payload files based on catalog responses.
|
|
func (d *DiskCatalog) OpenFile(filename string) (io.ReadCloser, error) {
|
|
file, err := os.Open(filename)
|
|
if err != nil {
|
|
if file, errx := os.Open(BackwardsCompatiblePaths(d.templatesDirectory, filename)); errx == nil {
|
|
return file, nil
|
|
}
|
|
}
|
|
return file, err
|
|
}
|