Skip to content

Commit

Permalink
fix changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bilalcaliskan committed Jan 3, 2022
1 parent f21e8fb commit 470f014
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 102 deletions.
179 changes: 89 additions & 90 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,42 @@ on:
types: [opened, synchronize, reopened]

jobs:
# lint:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# - name: Install Go
# uses: actions/setup-go@v2
# with:
# go-version: 1.16.x
# - name: Lint
# run: |
# curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.42.1
# make lint
# vet:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# - name: Install Go
# uses: actions/setup-go@v2
# with:
# go-version: 1.16.x
# - name: Vet
# run: make vet
#
# ineffassign:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# - name: Install Go
# uses: actions/setup-go@v2
# with:
# go-version: 1.16.x
# - name: Lint
# run: make ineffassign
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
- name: Lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.42.1
make lint
vet:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
- name: Vet
run: make vet

ineffassign:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
- name: Lint
run: make ineffassign

test:
runs-on: ubuntu-latest
Expand All @@ -53,58 +53,57 @@ jobs:
with:
go-version: 1.16.x
- name: Test
run: |
sudo go test ./... -v
run: make test

codeql:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

# codeql:
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# language: [ 'go' ]
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Initialize CodeQL
# uses: github/codeql-action/init@v1
# with:
# languages: ${{ matrix.language }}
# # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# # If this step fails, then you should remove it and run the build manually (see below)
# - name: Autobuild
# uses: github/codeql-action/autobuild@v1
# - name: Perform CodeQL Analysis
# uses: github/codeql-action/analyze@v1
#
# sonarcloud:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# with:
# fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
# - name: Install Go
# uses: actions/setup-go@v2
# with:
# go-version: 1.16.x
# - name: Coverage Test
# run: sudo go test ./... -race -coverprofile=coverage.txt -covermode=atomic
# - name: SonarCloud Scan
# uses: SonarSource/sonarcloud-github-action@master
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
#
# build:
# strategy:
# matrix:
# os: [ ubuntu-latest, macos-latest ]
# runs-on: ${{ matrix.os }}
# steps:
# - name: Install Go
# uses: actions/setup-go@v2
# with:
# go-version: 1.16.x
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Test
# run: make build
sonarcloud:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
- name: Coverage Test
run: sudo go test ./... -race -coverprofile=coverage.txt -covermode=atomic
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

build:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
- name: Checkout code
uses: actions/checkout@v2
- name: Test
run: make build
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ ineffassign:
ineffassign ./...

test:
sudo sysctl -w fs.file-max=100000000
sudo sysctl -p
sudo go test ./... -v

build:
Expand Down
18 changes: 8 additions & 10 deletions internal/raw/raw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package raw

import (
"context"
"github.com/stretchr/testify/assert"
"math/rand"
"testing"
"time"
Expand All @@ -18,17 +19,17 @@ func TestStartFlooding(t *testing.T) {
srcIp, dstIp string
srcMacAddr, dstMacAddr []byte
}{
{"5byte_syn", "syn", 5, srcPorts[rand.Intn(len(srcPorts))],
443, 100, srcIps[rand.Intn(len(srcIps))], "213.238.175.187",
{"10byte_syn", "syn", 10, srcPorts[rand.Intn(len(srcPorts))],
443, 10, srcIps[rand.Intn(len(srcIps))], "213.238.175.187",
macAddrs[rand.Intn(len(macAddrs))], macAddrs[rand.Intn(len(macAddrs))]},
{
"5byte_ack", "ack", 5, srcPorts[rand.Intn(len(srcPorts))],
443, 100, srcIps[rand.Intn(len(srcIps))], "213.238.175.187",
"10byte_ack", "ack", 10, srcPorts[rand.Intn(len(srcPorts))],
443, 10, srcIps[rand.Intn(len(srcIps))], "213.238.175.187",
macAddrs[rand.Intn(len(macAddrs))], macAddrs[rand.Intn(len(macAddrs))],
},
{
"5byte_synack", "synAck", 5, srcPorts[rand.Intn(len(srcPorts))],
443, 100, srcIps[rand.Intn(len(srcIps))], "213.238.175.187",
"10byte_synack", "synAck", 10, srcPorts[rand.Intn(len(srcPorts))],
443, 10, srcIps[rand.Intn(len(srcIps))], "213.238.175.187",
macAddrs[rand.Intn(len(macAddrs))], macAddrs[rand.Intn(len(macAddrs))],
},
}
Expand All @@ -41,10 +42,7 @@ func TestStartFlooding(t *testing.T) {
go func() {
t.Logf("starting flood, caseName=%s, floodType=%s, floodMilliSeconds=%d\n", tc.name, tc.floodType, tc.floodMilliSeconds)
err := StartFlooding(tc.dstIp, tc.dstPort, tc.payloadLength, tc.floodType)
if err != nil {
t.Errorf("flooding process returned an error: %s\n", err.Error())
return
}
assert.Nil(t, err)
t.Logf("ending flood, caseName=%s, floodType=%s, floodMilliSeconds=%d\n", tc.name, tc.floodType, tc.floodMilliSeconds)
cancel()
}()
Expand Down

0 comments on commit 470f014

Please sign in to comment.