55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
|
|
package main
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"fmt"
|
||
|
|
"log"
|
||
|
|
"net/mail"
|
||
|
|
"os"
|
||
|
|
"wazuh-notify/config"
|
||
|
|
logger "wazuh-notify/log"
|
||
|
|
|
||
|
|
"github.com/urfave/cli/v3"
|
||
|
|
)
|
||
|
|
|
||
|
|
func main() {
|
||
|
|
|
||
|
|
app := &cli.Command{
|
||
|
|
Name: "KleinCommand",
|
||
|
|
Usage: "CLI tool for internal use",
|
||
|
|
UsageText: "kleinCommand [category] [command] [arguments...]",
|
||
|
|
Version: "v0.1.0",
|
||
|
|
HideVersion: true,
|
||
|
|
Authors: []any{
|
||
|
|
mail.Address{
|
||
|
|
Name: "Darius",
|
||
|
|
Address: "darius.klein@dariusklein.nl",
|
||
|
|
},
|
||
|
|
},
|
||
|
|
DefaultCommand: "help",
|
||
|
|
Commands: []*cli.Command{
|
||
|
|
Notify(),
|
||
|
|
},
|
||
|
|
Before: func(context context.Context, c *cli.Command) (context.Context, error) {
|
||
|
|
const WazuhLogDir = "/var/ossec/logs/active-responses"
|
||
|
|
|
||
|
|
if err := os.MkdirAll(WazuhLogDir, 0755); err != nil {
|
||
|
|
fmt.Fprintf(os.Stderr, "Error creating log directory %s: %v\n", WazuhLogDir, err)
|
||
|
|
}
|
||
|
|
logger.OpenLogFile(WazuhLogDir)
|
||
|
|
|
||
|
|
config.Read()
|
||
|
|
|
||
|
|
return context, nil
|
||
|
|
},
|
||
|
|
After: func(context context.Context, c *cli.Command) error {
|
||
|
|
logger.CloseLogFile()
|
||
|
|
return nil
|
||
|
|
},
|
||
|
|
}
|
||
|
|
|
||
|
|
if err := app.Run(context.Background(), os.Args); err != nil {
|
||
|
|
log.Fatal(err)
|
||
|
|
}
|
||
|
|
}
|