Compare commits

10 Commits

Author SHA1 Message Date
2f297fd935 Fix debug flag
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-06-13 22:05:07 -07:00
eee5cb2fef Remove debug code
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-06-11 18:55:14 +00:00
6d5c7141fb Run hclfmt
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-06-09 20:38:43 -07:00
cf08c9e928 Close config file after decoding
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-06-09 20:32:58 -07:00
2a8cb0bb54 Set debug flag in nomad template
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-06-09 20:24:25 -07:00
3e4ae9cf27 Add riscv64 architecture
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-06-09 20:11:13 -07:00
57e35bc202 Remove branch restriction
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-06-09 20:06:44 -07:00
cb01f7554a Fix woodpecker config for deployment
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-06-09 12:37:36 -07:00
12869d1ec0 Only enable debug logging if debug flag is set
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-06-09 12:33:39 -07:00
0341c7c6b3 Return generic error for incorrect webhook password 2023-06-09 12:32:40 -07:00
5 changed files with 27 additions and 20 deletions

View File

@@ -13,6 +13,7 @@ builds:
- 386 - 386
- arm64 - arm64
- arm - arm
- riscv64
archives: archives:
- id: archive - id: archive
name_template: "{{ .ProjectName }}-{{ .Arch }}" name_template: "{{ .ProjectName }}-{{ .Arch }}"

View File

@@ -17,5 +17,4 @@ pipeline:
- PLUGIN_WATCH_DEPLOYMENT=true - PLUGIN_WATCH_DEPLOYMENT=true
- PLUGIN_WATCH_DEPLOYMENT_TIMEOUT=10m - PLUGIN_WATCH_DEPLOYMENT_TIMEOUT=10m
when: when:
branch: public event: tag
event: push

View File

@@ -41,6 +41,7 @@ var (
ErrInvalidHdrVal = errors.New("invalid header value type") ErrInvalidHdrVal = errors.New("invalid header value type")
ErrInvalidType = errors.New("invalid type") ErrInvalidType = errors.New("invalid type")
ErrInsecureWebhook = errors.New("secure webhook missing authorization") ErrInsecureWebhook = errors.New("secure webhook missing authorization")
ErrIncorrectPassword = errors.New("incorrect password")
) )
var httpModule = &starlarkstruct.Module{ var httpModule = &starlarkstruct.Module{
@@ -352,10 +353,8 @@ func verifySecure(pwdHash, pluginName string, req *http.Request) error {
return ErrInsecureWebhook return ErrInsecureWebhook
} }
fmt.Println(string(pwd))
if err := bcrypt.CompareHashAndPassword([]byte(pwdHash), pwd); err != nil { if err := bcrypt.CompareHashAndPassword([]byte(pwdHash), pwd); err != nil {
return err return ErrIncorrectPassword
} }
return nil return nil

10
main.go
View File

@@ -41,7 +41,6 @@ import (
func init() { func init() {
log.Logger = logger.NewPretty(os.Stderr) log.Logger = logger.NewPretty(os.Stderr)
log.Logger.SetLevel(logger.LogLevelDebug)
} }
func main() { func main() {
@@ -51,8 +50,13 @@ func main() {
serverAddr := pflag.StringP("address", "a", ":8080", "Webhook server address") serverAddr := pflag.StringP("address", "a", ":8080", "Webhook server address")
genHash := pflag.BoolP("gen-hash", "g", false, "Generate a password hash for webhooks") genHash := pflag.BoolP("gen-hash", "g", false, "Generate a password hash for webhooks")
useEnv := pflag.BoolP("use-env", "E", false, "Use environment variables for configuration") useEnv := pflag.BoolP("use-env", "E", false, "Use environment variables for configuration")
debug := pflag.BoolP("debug", "D", false, "Enable debug logging")
pflag.Parse() pflag.Parse()
if *debug {
log.Logger.SetLevel(logger.LogLevelDebug)
}
if *genHash { if *genHash {
fmt.Print("Password: ") fmt.Print("Password: ")
pwd, err := term.ReadPassword(int(os.Stdin.Fd())) pwd, err := term.ReadPassword(int(os.Stdin.Fd()))
@@ -87,6 +91,10 @@ func main() {
if err != nil { if err != nil {
log.Fatal("Error decoding config file").Err(err).Send() log.Fatal("Error decoding config file").Err(err).Send()
} }
err = fl.Close()
if err != nil {
log.Fatal("Error closing config file").Err(err).Send()
}
} }
if _, err := os.Stat(cfg.Git.RepoDir); os.IsNotExist(err) { if _, err := os.Stat(cfg.Git.RepoDir); os.IsNotExist(err) {

View File

@@ -11,8 +11,8 @@ job "lure-updater" {
} }
volume "lure-updater-data" { volume "lure-updater-data" {
type = "host" type = "host"
source = "lure-updater-data" source = "lure-updater-data"
read_only = false read_only = false
} }
@@ -20,20 +20,20 @@ job "lure-updater" {
driver = "docker" driver = "docker"
volume_mount { volume_mount {
volume = "lure-updater-data" volume = "lure-updater-data"
destination = "/etc/lure-updater" destination = "/etc/lure-updater"
read_only = false read_only = false
} }
env { env {
GIT_REPO_DIR="/etc/lure-updater/repo" GIT_REPO_DIR = "/etc/lure-updater/repo"
GIT_REPO_URL="https://github.com/Elara6331/lure-repo.git" GIT_REPO_URL = "https://github.com/Elara6331/lure-repo.git"
GIT_CREDENTIALS_USERNAME="lure-repo-bot" GIT_CREDENTIALS_USERNAME = "lure-repo-bot"
GIT_CREDENTIALS_PASSWORD="${GITHUB_PASSWORD}" GIT_CREDENTIALS_PASSWORD = "${GITHUB_PASSWORD}"
GIT_COMMIT_NAME="lure-repo-bot" GIT_COMMIT_NAME = "lure-repo-bot"
GIT_COMMIT_EMAIL="lure@elara.ws" GIT_COMMIT_EMAIL = "lure@elara.ws"
WEBHOOK_PASSWORD_HASH="${PASSWORD_HASH}" WEBHOOK_PASSWORD_HASH = "${PASSWORD_HASH}"
// Hack to force Nomad to re-deploy the service // Hack to force Nomad to re-deploy the service
// instead of ignoring it // instead of ignoring it
COMMIT_SHA = "${DRONE_COMMIT_SHA}" COMMIT_SHA = "${DRONE_COMMIT_SHA}"
@@ -41,10 +41,10 @@ job "lure-updater" {
config { config {
image = "alpine:latest" image = "alpine:latest"
command = "/opt/lure-updater/lure-updater"
args = ["-DE"]
ports = ["webhook"] ports = ["webhook"]
volumes = ["local/lure-updater/:/opt/lure-updater:ro"] volumes = ["local/lure-updater/:/opt/lure-updater:ro"]
command = "/opt/lure-updater/lure-updater"
args = ["-E"]
} }
artifact { artifact {