Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/docker/docker-runner/ubuntu-24.04
Browse files Browse the repository at this point in the history
  • Loading branch information
zakird authored Nov 4, 2024
2 parents 1a242ed + 82b0038 commit 74d625c
Show file tree
Hide file tree
Showing 98 changed files with 5,773 additions and 5,659 deletions.
34 changes: 25 additions & 9 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@ jobs:
name: Go Test
runs-on: ubuntu-latest
steps:
- name: Check out source
uses: actions/checkout@v4

- name: Read go version
id: go_version
run: |
# Read the variable from the file
GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}')
# Set the variable as an output
echo "GO_VERSION=$GO_VERSION" >> $GITHUB_OUTPUT
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.18

- name: Check out source
uses: actions/checkout@v4
go-version: ${{ steps.go_version.outputs.GO_VERSION }}

- name: Build
run: |
Expand All @@ -31,13 +39,21 @@ jobs:
name: Integration Test
runs-on: ubuntu-latest
steps:
- name: Check out source
uses: actions/checkout@v4

- name: Read go version
id: go_version
run: |
# Read the variable from the file
GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}')
# Set the variable as an output
echo "GO_VERSION=$GO_VERSION" >> $GITHUB_OUTPUT
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.18

- name: Check out source
uses: actions/checkout@v4
go-version: ${{ steps.go_version.outputs.GO_VERSION }}

- name: Install dependencies
run: |
Expand All @@ -55,4 +71,4 @@ jobs:
- name: Run tests
run: |
make integration-test
make integration-test
31 changes: 28 additions & 3 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,37 @@ jobs:
go-fmt:
name: Go Formatter
runs-on: ubuntu-latest
if: false # Pending activation
steps:
- uses: actions/checkout@v4
- name: Read go version
id: go_version
run: |
# Read the variable from the file
GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}')
# Set the variable as an output
echo "GO_VERSION=$GO_VERSION" >> $GITHUB_OUTPUT
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.18
go-version: ${{ steps.go_version.outputs.GO_VERSION }}
- name: Run go fmt
run: go fmt ./...
run: |
NON_COMPLIANT_FILES=$(gofmt -s -l $(find . -type f -name '*.go'| grep -v "/.template/"))
if [ -n "$NON_COMPLIANT_FILES" ]; then
echo "The following files are not formatted correctly:"
echo "$NON_COMPLIANT_FILES"
mkdir -p /tmp/gofmt
for file in $NON_COMPLIANT_FILES; do
mkdir -p /tmp/gofmt/$(dirname $file)
gofmt -s $file > /tmp/gofmt/$file
done
exit 1
fi
- name: Upload formatted files
if: failure()
uses: actions/upload-artifact@v4
with:
name: formatted-files
path: /tmp/gofmt
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Build image ##
FROM golang:1.20.4-alpine3.16 as build
ARG GO_VERSION=1.20
FROM golang:${GO_VERSION}-alpine3.16 as build

# System dependencies
RUN apk add --no-cache make
Expand All @@ -15,7 +16,7 @@ COPY . .
RUN make all

## Runtime image ##
FROM alpine:3.19 as run
FROM alpine:3.20 as run

COPY --from=build /usr/src/zgrab2/cmd/zgrab2/zgrab2 /usr/bin/zgrab2

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ test:
cd lib/output/test && go test -v ./...
cd modules && go test -v ./...

gofmt:
goimports -w -l $(GO_FILES)
lint:
gofmt -s -w $(shell find . -type f -name '*.go'| grep -v "/.template/")

zgrab2: $(GO_FILES)
cd cmd/zgrab2 && go build && cd ../..
Expand Down
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,25 @@ ZGrab is a fast, modular application-layer network scanner designed for completi

ZGrab 2.0 contains a new, modular ZGrab framework, which fully supersedes https://github.com/zmap/zgrab.

## Installation

## Building
### With Docker

You can run ZGrab 2.0 with our official Docker image. For example, to scan a single website using the HTTP module, you can use:

```shell
echo 'example.com' | docker run --rm -i ghcr.io/zmap/zgrab2 http
```

For more complex scanning scenarios, such as using multiple modules or custom configurations, you can create a configuration file and pass it to the container:

```shell
docker run --rm -i -v /path/to/your/config.ini:/config.ini ghcr.io/zmap/zgrab2 multiple -c /config.ini
```

Replace `/path/to/your/config.ini` with the path to your configuration file on the host machine. See [Multiple Module Usage](#multiple-module-usage) for more details on configurations.

### Building from Source

For Go 1.17 and later you must build from source:

Expand Down
6 changes: 3 additions & 3 deletions conn_timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func _write(writer io.Writer, data []byte) error {

// Run the configured server. As soon as it returns, it is listening.
// Returns a channel that receives a timeoutTestError on error, or is closed on successful completion.
func (cfg *connTimeoutTestConfig) runServer(t *testing.T) (chan *timeoutTestError) {
func (cfg *connTimeoutTestConfig) runServer(t *testing.T) chan *timeoutTestError {
errorChan := make(chan *timeoutTestError)
if cfg.endpoint != "" {
// Only listen on localhost
Expand Down Expand Up @@ -307,7 +307,7 @@ var connTestConfigs = []connTimeoutTestConfig{
serverToClientPayload: []byte("abc"),
clientToServerPayload: []byte("defghi"),

failStep: testStepConnect,
failStep: testStepConnect,
failError: "i/o timeout",
},
// short session timeout, medium connect timeout, with connect to nonexistent endpoint.
Expand All @@ -326,7 +326,7 @@ var connTestConfigs = []connTimeoutTestConfig{
serverToClientPayload: []byte("abc"),
clientToServerPayload: []byte("defghi"),

failStep: testStepConnect,
failStep: testStepConnect,
failError: "i/o timeout",
},
// Get an IO timeout on the read.
Expand Down
23 changes: 17 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
module github.com/zmap/zgrab2

go 1.12
go 1.20

require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/hdm/jarm-go v0.0.7
github.com/prometheus/client_golang v1.14.0
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/rabbitmq/amqp091-go v1.9.0
github.com/sirupsen/logrus v1.9.0
github.com/zmap/zcrypto v0.0.0-20230310154051-c8b263fd8300
github.com/zmap/zflags v1.4.0-beta.1.0.20200204220219-9d95409821b6
golang.org/x/crypto v0.23.0
golang.org/x/net v0.25.0
golang.org/x/sys v0.20.0
golang.org/x/text v0.15.0
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/kr/pretty v0.2.1 // indirect
github.com/kr/text v0.1.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/weppos/publicsuffix-go v0.30.0 // indirect
github.com/zmap/rc2 v0.0.0-20190804163417-abaa70531248 // indirect
google.golang.org/protobuf v1.33.0 // indirect
)
Loading

0 comments on commit 74d625c

Please sign in to comment.