fixing some issues with file removing
This commit is contained in:
committed by
satti-hari-krishna-reddy
parent
4eba465457
commit
bf745db0fb
@@ -2040,7 +2040,7 @@ func main() {
|
||||
|
||||
toBeRemoved.Data = append(toBeRemoved.Data, incRequest)
|
||||
|
||||
} else if incRequest.Type == "DISABLE_SIGMA_RULES" {
|
||||
} else if incRequest.Type == "DISABLE_SIGMA_FOLDER" {
|
||||
err := removeAllFiles()
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] Failed to disable the sigma rules: %s", err)
|
||||
@@ -2426,11 +2426,6 @@ func handlePipeline(incRequest shuffle.ExecutionRequest) error {
|
||||
log.Printf("[ERROR] Failed to create pipeline: %s", err)
|
||||
return err
|
||||
}
|
||||
err = handleFileCategoryChange()
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] Failed to download rules: %s", err)
|
||||
return err
|
||||
}
|
||||
} else if incRequest.Type == "PIPELINE_DELETE" {
|
||||
log.Printf("[INFO] Should delete pipeline %#v", identifier)
|
||||
pipelineId, err := searchPipeline(identifier)
|
||||
@@ -2999,7 +2994,7 @@ func extractFile(f *zip.File, destDir string) error {
|
||||
func copyToTenzir(srcPath, destPath string) error {
|
||||
containerName := "tenzir-node"
|
||||
|
||||
// Check if the extracted_files directory exists in the container
|
||||
// Check if the sigma_rules directory exists in the container
|
||||
checkCmd := exec.Command("docker", "exec", containerName, "test", "-d", destPath)
|
||||
if err := checkCmd.Run(); err == nil {
|
||||
rmCmd := exec.Command("docker", "exec", "-u", "root", containerName, "rm", "-rf", destPath)
|
||||
@@ -3022,6 +3017,13 @@ func copyToTenzir(srcPath, destPath string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func removeAllFiles() error {
|
||||
containerName := "tenzir-node"
|
||||
sigmaPath := "/var/lib/tenzir/sigma_rules/*"
|
||||
|
||||
return removePath(containerName, sigmaPath)
|
||||
}
|
||||
|
||||
func removeFile(fileName string) error {
|
||||
containerName := "tenzir-node"
|
||||
srcPath := fmt.Sprintf("/var/lib/tenzir/sigma_rules/%s", fileName)
|
||||
@@ -3034,22 +3036,15 @@ func removeFile(fileName string) error {
|
||||
return removePath(containerName, srcPath)
|
||||
}
|
||||
|
||||
func removeAllFiles() error {
|
||||
containerName := "tenzir-node"
|
||||
sigmaPath := "/var/lib/tenzir/sigma_rules/*"
|
||||
|
||||
return removePath(containerName, sigmaPath)
|
||||
}
|
||||
|
||||
func removePath(containerName, path string) error {
|
||||
rmCmd := exec.Command("docker", "exec", "-u", "root", containerName, "rm", "-r", path)
|
||||
if err := rmCmd.Run(); err != nil {
|
||||
return fmt.Errorf("error removing path: %v", err)
|
||||
rmCmd := exec.Command("docker", "exec", "-u", "root", containerName, "rm", "-rf", path)
|
||||
output, err := rmCmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error removing path: %v, output: %s", err, output)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
// func savePipelineData(pipelineId, identifier, status string) error {
|
||||
|
||||
// url := fmt.Sprintf("%s/api/v1/triggers/pipeline/save", baseUrl)
|
||||
|
||||
Reference in New Issue
Block a user