update the config.yaml file (#674)

This commit is contained in:
AlteredCoder 2021-03-11 11:18:09 +01:00 committed by GitHub
parent 0981aa98d8
commit f2d14c8ca2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 44 additions and 19 deletions

View file

@ -22,11 +22,17 @@ jobs:
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- id: keydb
uses: pozetroninc/github-action-get-latest-release@master
with:
owner: crowdsecurity
repo: crowdsec
excludes: draft
- name: Build release
run: BUILD_VERSION=xxx make release
run: BUILD_VERSION=${{ steps.keydb.outputs.release }} make release
- name: Install release
run: |
cd crowdsec-xxx
cd crowdsec-${{ steps.keydb.outputs.release }}
sudo bash -x ./wizard.sh --bininstall
sudo cscli machines add -a
- name: Post-installation check

View file

@ -25,9 +25,15 @@ jobs:
- name: install ipset for bouncer
run: |
sudo apt update
sudo apt install ipset
sudo apt install ipset git
- id: keydb
uses: pozetroninc/github-action-get-latest-release@master
with:
owner: crowdsecurity
repo: crowdsec
excludes: draft
- name: run tests
run: |
cd scripts
sudo ./test_wizard_upgrade.sh
sudo ./test_wizard_upgrade.sh --version ${{ steps.keydb.outputs.release }}

View file

@ -71,23 +71,22 @@ func setHubBranch() error {
/*
if no branch has been specified in flags for the hub, then use the one corresponding to crowdsec version
*/
if cwhub.HubBranch == "" {
latest, err := cwversion.Latest()
if err != nil {
cwhub.HubBranch = "master"
return err
}
if cwversion.Version == latest {
csVersion := cwversion.VersionStrip()
if csVersion == latest {
cwhub.HubBranch = "master"
} else if semver.Compare(cwversion.Version, latest) == 1 { // if current version is greater than the latest we are in pre-release
log.Debugf("Your current crowdsec version seems to be a pre-release (%s)", cwversion.Version)
} else if semver.Compare(csVersion, latest) == 1 { // if current version is greater than the latest we are in pre-release
log.Debugf("Your current crowdsec version seems to be a pre-release (%s)", csVersion)
cwhub.HubBranch = "master"
} else {
log.Warnf("Crowdsec is not the latest version. Current version is '%s' and latest version is '%s'. Please update it!", cwversion.Version, latest)
log.Warnf("Crowdsec is not the latest version. Current version is '%s' and the latest stable version is '%s'. Please update it!", csVersion, latest)
log.Warnf("As a result, you will not be able to use parsers/scenarios/collections added to Crowdsec Hub after CrowdSec %s", latest)
cwhub.HubBranch = cwversion.Version
cwhub.HubBranch = csVersion
}
log.Debugf("Using branch '%s' for the hub", cwhub.HubBranch)
}

View file

@ -16,7 +16,6 @@ crowdsec_service:
parser_routines: 1
cscli:
output: human
hub_branch: master
db_config:
log_level: info
type: sqlite

View file

@ -5,6 +5,7 @@ import (
"fmt"
"log"
"net/http"
"strings"
version "github.com/hashicorp/go-version"
)
@ -57,6 +58,11 @@ func VersionStr() string {
return fmt.Sprintf("%s-%s", Version, Tag)
}
func VersionStrip() string {
version := strings.Split(Version, "-")
return version[0]
}
func Statisfies(strvers string, constraint string) (bool, error) {
vers, err := version.NewVersion(strvers)
if err != nil {

View file

@ -70,8 +70,7 @@ func (c *Client) QueryMachineByID(machineID string) (*ent.Machine, error) {
func (c *Client) ListMachines() ([]*ent.Machine, error) {
machines, err := c.Ent.Machine.Query().All(c.CTX)
if err != nil {
log.Warningf("ListMachines : %s", err)
return []*ent.Machine{}, errors.Wrap(UpdateFail, "setting machine status")
return []*ent.Machine{}, errors.Wrapf(QueryFail, "listing machines: %s", err)
}
return machines, nil
}
@ -79,8 +78,7 @@ func (c *Client) ListMachines() ([]*ent.Machine, error) {
func (c *Client) ValidateMachine(machineID string) error {
_, err := c.Ent.Machine.Update().Where(machine.MachineIdEQ(machineID)).SetIsValidated(true).Save(c.CTX)
if err != nil {
log.Warningf("ValidateMachine : %s", err)
return errors.Wrap(UpdateFail, "setting machine status")
return errors.Wrapf(UpdateFail, "validating machine: %s", err)
}
return nil
}
@ -92,7 +90,7 @@ func (c *Client) QueryPendingMachine() ([]*ent.Machine, error) {
machines, err = c.Ent.Machine.Query().Where(machine.IsValidatedEQ(false)).All(c.CTX)
if err != nil {
log.Warningf("QueryPendingMachine : %s", err)
return []*ent.Machine{}, errors.Wrap(UpdateFail, "setting machine status")
return []*ent.Machine{}, errors.Wrapf(QueryFail, "querying pending machines: %s", err)
}
return machines, nil
}

View file

@ -11,7 +11,6 @@ FAIL_STR="${RED}FAIL${NC}"
CURRENT_FOLDER=$(pwd)
BOUNCER_VERSION="v0.0.6"
CROWDSEC_VERSION="xxx"
RELEASE_FOLDER=""
HUB_AVAILABLE_PARSERS="/etc/crowdsec/hub/parsers"
@ -40,6 +39,10 @@ MUST_FAIL=0
function init
{
which git > /dev/null
if [ $? -ne 0 ]; then
echo "git is needed this test, exiting ..."
fi
if [[ -z ${RELEASE_FOLDER} ]];
then
cd ..
@ -324,7 +327,12 @@ while [[ $# -gt 0 ]]
do
key="${1}"
case ${key} in
--release)
--version|-v)
CROWDSEC_VERSION="${2}"
shift #past argument
shift
;;
--release|-r)
RELEASE_FOLDER="${2}"
shift #past argument
shift

View file

@ -22,6 +22,8 @@ CROWDSEC_DB_PATH="${CROWDSEC_DATA_DIR}/crowdsec.db"
CROWDSEC_PATH="/etc/crowdsec"
CROWDSEC_CONFIG_PATH="${CROWDSEC_PATH}"
CROWDSEC_LOG_FILE="/var/log/crowdsec.log"
LAPI_LOG_FILE="/var/log/crowdsec_api.log"
CROWDSEC_BIN="./cmd/crowdsec/crowdsec"
CSCLI_BIN="./cmd/crowdsec-cli/cscli"
@ -477,6 +479,7 @@ uninstall_crowdsec() {
find /etc/crowdsec -maxdepth 1 -mindepth 1 | grep -v "bouncer" | xargs rm -rf || echo ""
rm -f ${CROWDSEC_LOG_FILE} || echo ""
rm -f ${LAPI_LOG_FILE} || echo ""
rm -f ${CROWDSEC_DB_PATH} || echo ""
rm -rf ${CROWDSEC_LIB_DIR} || echo ""
rm -rf ${CROWDSEC_USR_DIR} || echo ""