Skip to content

Commit

Permalink
feat/agent change (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
davideimola authored Jan 2, 2024
1 parent 237df91 commit 09190b3
Show file tree
Hide file tree
Showing 52 changed files with 1,900 additions and 5,613 deletions.
32 changes: 0 additions & 32 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@ on:
pull_request:

jobs:
# golangci must be the first job as it has different problems
golangci:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.19
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.49.0
args: --timeout 5m
skip-pkg-cache: true
test:
runs-on: ubuntu-latest
permissions:
Expand All @@ -46,21 +32,3 @@ jobs:
- uses: bufbuild/buf-breaking-action@v1
with:
against: "https://github.com/${GITHUB_REPOSITORY}.git#branch=main"
codegen:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19
- name: Prepare
run: make install-tools
- name: generate
run: make generate
- name: check diff
run: git diff --exit-code
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ go.work
.vscode

*.DS_Store

.config.yaml

dist/
25 changes: 0 additions & 25 deletions .golangci.yml

This file was deleted.

22 changes: 5 additions & 17 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,8 @@ archives:
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
wrap_in_directory: true
format: tar.gz

nfpms:
- license: Apache 2.0
maintainer: RedCarbon SA
vendor: RedCarbon SA
homepage: https://redcarbon.ai
bindir: /usr
description: RedCarbon's Agent
formats:
- deb
- rpm
contents:
- src: ./service/redcarbon.service
dst: /etc/systemd/system/redcarbon.service
type: config
scripts:
postinstall: ./scripts/post_install.sh
files:
- src: assets/*
dst: .
- src: templates/*
dst: bin/templates
16 changes: 6 additions & 10 deletions .proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
version: v1
lint:
use:
- BASIC
- FILE_LOWER_SNAKE_CASE
except:
- ENUM_NO_ALLOW_ALIAS
- IMPORT_NO_PUBLIC
- PACKAGE_DIRECTORY_MATCH
- PACKAGE_SAME_DIRECTORY
breaking:
use:
- WIRE_JSON
- FILE
lint:
use:
- DEFAULT
ignore:
- google/type/datetime.proto
13 changes: 13 additions & 0 deletions .proto/redcarbon/agents_public/v1/types.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
syntax = "proto3";

package redcarbon.agents_public.v1;

message AgentConfiguration {
optional QRadarJobConfiguration qradar_job_configuration = 1;
}

message QRadarJobConfiguration {
string host = 1;
string token = 2;
bool verify_ssl = 3;
}
38 changes: 38 additions & 0 deletions .proto/redcarbon/agents_public/v1/v1.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
syntax = "proto3";

package redcarbon.agents_public.v1;

import "google/protobuf/timestamp.proto";
import "redcarbon/agents_public/v1/types.proto";

service AgentsPublicAPIsV1Srv {
rpc HZ(HZRequest) returns (HZResponse) {}
rpc IngestIncident(IngestIncidentRequest) returns (IngestIncidentResponse) {}
rpc FetchAgentConfiguration(FetchAgentConfigurationRequest) returns (FetchAgentConfigurationResponse) {}
}

message HZRequest {
string hostname = 1;
string ip = 2;
}

message HZResponse {
google.protobuf.Timestamp received_at = 1;
}

message IngestIncidentRequest {
string title = 1;
string description = 2;
string raw_data = 3;
uint32 severity = 4;
string origin = 5;
optional string original_id = 6;
}

message IngestIncidentResponse {}

message FetchAgentConfigurationRequest {}

message FetchAgentConfigurationResponse {
AgentConfiguration configuration = 1;
}
68 changes: 0 additions & 68 deletions .proto/redcarbon/public_apis/agents/api/v1/types.proto

This file was deleted.

104 changes: 0 additions & 104 deletions .proto/redcarbon/public_apis/agents/api/v1/v1.proto

This file was deleted.

23 changes: 23 additions & 0 deletions assets/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

user_id=`id -u`

# we want to snapshot the environment of the config user
if [ $user_id -eq 0 -a -z "$AGENT_ALLOW_RUNASROOT" ]; then
echo "Must not run with sudo"
exit 1
fi

# Change directory to the script root directory
# https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
cd "$DIR"

shopt -s nocasematch
./bin/redcarbon configure "$@"
Loading

0 comments on commit 09190b3

Please sign in to comment.