-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into tpl-http-port-path-preference
- Loading branch information
Showing
19 changed files
with
273 additions
and
201 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
FROM golang:1.14-alpine AS build-env | ||
FROM golang:alpine as builder | ||
|
||
RUN apk add --no-cache --upgrade git openssh-client ca-certificates | ||
RUN go get -u github.com/golang/dep/cmd/dep | ||
WORKDIR /go/src/app | ||
RUN mkdir -p /app | ||
WORKDIR /app | ||
COPY ./go.mod . | ||
RUN go mod download | ||
|
||
# Install | ||
RUN GO111MODULE=on go get -u github.com/projectdiscovery/nuclei/v2/cmd/nuclei | ||
COPY . . | ||
RUN cd ./cmd/nuclei && go build -o nuclei . | ||
|
||
ENTRYPOINT ["nuclei"] | ||
FROM alpine | ||
|
||
RUN mkdir /app | ||
RUN adduser -S -D -H -h /app appuser | ||
USER appuser | ||
COPY --from=builder /app/cmd/nuclei/nuclei /app | ||
|
||
WORKDIR /app | ||
CMD ["./nuclei"] |
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,74 @@ | ||
package bufwriter | ||
|
||
import ( | ||
"bufio" | ||
"os" | ||
"sync" | ||
) | ||
|
||
// Writer is a mutex protected buffered writer | ||
type Writer struct { | ||
file *os.File | ||
writer *bufio.Writer | ||
mutex *sync.Mutex | ||
} | ||
|
||
// New creates a new mutex protected buffered writer for a file | ||
func New(file string) (*Writer, error) { | ||
output, err := os.Create(file) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &Writer{file: output, writer: bufio.NewWriter(output), mutex: &sync.Mutex{}}, nil | ||
} | ||
|
||
// Write writes a byte slice to the underlying file | ||
// | ||
// It also writes a newline if the last byte isn't a newline character. | ||
func (w *Writer) Write(data []byte) error { | ||
if len(data) == 0 { | ||
return nil | ||
} | ||
w.mutex.Lock() | ||
defer w.mutex.Unlock() | ||
|
||
_, err := w.writer.Write(data) | ||
if err != nil { | ||
return err | ||
} | ||
if data[len(data)-1] != '\n' { | ||
_, err = w.writer.WriteRune('\n') | ||
} | ||
return err | ||
} | ||
|
||
// WriteString writes a string to the underlying file | ||
// | ||
// It also writes a newline if the last byte isn't a newline character. | ||
func (w *Writer) WriteString(data string) error { | ||
if data == "" { | ||
return nil | ||
} | ||
w.mutex.Lock() | ||
defer w.mutex.Unlock() | ||
|
||
_, err := w.writer.WriteString(data) | ||
if err != nil { | ||
return err | ||
} | ||
if data[len(data)-1] != '\n' { | ||
_, err = w.writer.WriteRune('\n') | ||
} | ||
return err | ||
} | ||
|
||
// Close closes the underlying writer flushing everything to disk | ||
func (w *Writer) Close() error { | ||
w.mutex.Lock() | ||
defer w.mutex.Unlock() | ||
|
||
w.writer.Flush() | ||
//nolint:errcheck // we don't care whether sync failed or succeeded. | ||
w.file.Sync() | ||
return w.file.Close() | ||
} |
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
Oops, something went wrong.