Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update go to v21 GitHub action release exe #4

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# https://goreleaser.com/customization/builds/
name: goreleaser

on:
release:
types:
- created


permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v4
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
goreleaser
dist/
31 changes: 31 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

builds:
- env:
- CGO_ENABLED=0
targets:
- linux_amd64
- linux_arm64
# NOTE: errors on build
# - darwin_arm64
# - darwin_amd64
# - windows_amd64
# - windows_arm64

archives:
- format: tar.gz
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
39 changes: 8 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,38 +1,15 @@
# Copyright 2020-2021 Azul Systems, Inc. All rights reserved.
# Use of this source code is governed by the 3-Clause BSD
# license that can be found in the LICENSE file.
MYDIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

APP := jdowser
SCRIPT := ansible-jdowser
# ./jdowser start
# ./jdowser status
# ./jdowser -json report > output_file.json
# ./jdowser -csv report > output_file.csv

GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)

FILES := \
classfile.go \
classfilereader.go \
config.go \
jvminstallation.go \
main.go \
scanlock.go \
status.go \
utils.go \
build-dist:
rm -rf dist
CGO_ENABLED=0 go build -o dist/jdowser main.go
cp ansible-jdowser dist/ansible-jdowser.sh

all: $(APP) $(SCRIPT)

$(APP): $(FILES:%=$(MYDIR)/src/%) $(VERSION)
V=$$($(MYDIR)/src/version.sh) && \
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags="-s -w -X \"main.VERSION=$${V}\"" -o $@ $^

$(SCRIPT): $(MYDIR)/src/$(SCRIPT)
V=$$($(MYDIR)/src/version.sh) && \
sed "s#%VERSION%#$${V}#" $^ > $@ && chmod +x $@

resolve:
go get -u golang.org/x/sys/unix

clean:
rm -f $(APP) $(SCRIPT)

.PHONY: clean resolve all
34 changes: 25 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,14 @@ The application is written in Golang, so you need to have a Golang package [inst
To build JDowser:

1. Clone the JDowser project from the GitHub repository.
2. In your terminal, `cd` to the JDowser project directory.
3. Run `make`:
2. In your terminal run `make build-dist`:
```shell
$ make
$ make build-dist
```
This generates the `jdowser` executable file.
This will generate the `jdowser` executable file in the `dist` folder.

You can also use the already built binaries from the **Releases** section.

4. (Optional) If you observe dependency errors, run:
```shell
$ make resolve; \
make
```

## JDowser usage

Expand Down Expand Up @@ -77,10 +73,20 @@ If you specify this parameter, the default values are ignored.

## Sample JDowser run

Start scanning filesystem, this will run in background.

```shell
$ ./jdowser -root=/opt start
```

Or

```shell
$ ./jdowser start
```

Get scanning status Running/Finished.

```shell
$ ./jdowser status

Expand All @@ -91,6 +97,8 @@ end_time: -1
args: -root=/opt
```

You can output the status to json format

```shell
$ ./jdowser -json status

Expand All @@ -105,6 +113,8 @@ $ ./jdowser -json status
}
```

And, finally you can get a report simple (as below) in json or csv format.

```shell
$ ./jdowser report

Expand All @@ -122,6 +132,12 @@ java_vm_version: 11.0.7+10-LTS
java_vm_vendor: Azul Systems, Inc.
```

These commands will save data into specified files:
```shell
$ ./jdowser -json report > output_file.json
$ ./jdowser -csv report > output_file.csv
```


## Use JDowser with Ansible

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module jdowser

go 1.13
go 1.21

require golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7 // indirect
require golang.org/x/sys v0.13.0
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7 h1:c20P3CcPbopVp2f7099WLOqSNKURf30Z0uq66HpijZY=
golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
5 changes: 3 additions & 2 deletions src/classfile.go → jdowser/classfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
// Use of this source code is governed by the 3-Clause BSD
// license that can be found in the LICENSE file.

package main
package jdowser

import (
"fmt"
"log"

)

type ConstantPool []ConstantPoolEntry
Expand Down Expand Up @@ -337,7 +338,7 @@ func (e *ConstantUtf8Entry) Read(r *ClassFileReader) int {
}

func (e *ConstantUtf8Entry) String() string {
return fmt.Sprintf("%s", e.bytes)
return string(e.bytes)
}

func (e *ConstantMethodHandleEntry) Read(r *ClassFileReader) int {
Expand Down
2 changes: 1 addition & 1 deletion src/classfilereader.go → jdowser/classfilereader.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by the 3-Clause BSD
// license that can be found in the LICENSE file.

package main
package jdowser

import "encoding/binary"

Expand Down
Loading