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)
|
toBeRemoved.Data = append(toBeRemoved.Data, incRequest)
|
||||||
|
|
||||||
} else if incRequest.Type == "DISABLE_SIGMA_RULES" {
|
} else if incRequest.Type == "DISABLE_SIGMA_FOLDER" {
|
||||||
err := removeAllFiles()
|
err := removeAllFiles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERROR] Failed to disable the sigma rules: %s", err)
|
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)
|
log.Printf("[ERROR] Failed to create pipeline: %s", err)
|
||||||
return 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" {
|
} else if incRequest.Type == "PIPELINE_DELETE" {
|
||||||
log.Printf("[INFO] Should delete pipeline %#v", identifier)
|
log.Printf("[INFO] Should delete pipeline %#v", identifier)
|
||||||
pipelineId, err := searchPipeline(identifier)
|
pipelineId, err := searchPipeline(identifier)
|
||||||
@@ -2999,7 +2994,7 @@ func extractFile(f *zip.File, destDir string) error {
|
|||||||
func copyToTenzir(srcPath, destPath string) error {
|
func copyToTenzir(srcPath, destPath string) error {
|
||||||
containerName := "tenzir-node"
|
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)
|
checkCmd := exec.Command("docker", "exec", containerName, "test", "-d", destPath)
|
||||||
if err := checkCmd.Run(); err == nil {
|
if err := checkCmd.Run(); err == nil {
|
||||||
rmCmd := exec.Command("docker", "exec", "-u", "root", containerName, "rm", "-rf", destPath)
|
rmCmd := exec.Command("docker", "exec", "-u", "root", containerName, "rm", "-rf", destPath)
|
||||||
@@ -3022,6 +3017,13 @@ func copyToTenzir(srcPath, destPath string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func removeAllFiles() error {
|
||||||
|
containerName := "tenzir-node"
|
||||||
|
sigmaPath := "/var/lib/tenzir/sigma_rules/*"
|
||||||
|
|
||||||
|
return removePath(containerName, sigmaPath)
|
||||||
|
}
|
||||||
|
|
||||||
func removeFile(fileName string) error {
|
func removeFile(fileName string) error {
|
||||||
containerName := "tenzir-node"
|
containerName := "tenzir-node"
|
||||||
srcPath := fmt.Sprintf("/var/lib/tenzir/sigma_rules/%s", fileName)
|
srcPath := fmt.Sprintf("/var/lib/tenzir/sigma_rules/%s", fileName)
|
||||||
@@ -3034,22 +3036,15 @@ func removeFile(fileName string) error {
|
|||||||
return removePath(containerName, srcPath)
|
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 {
|
func removePath(containerName, path string) error {
|
||||||
rmCmd := exec.Command("docker", "exec", "-u", "root", containerName, "rm", "-r", path)
|
rmCmd := exec.Command("docker", "exec", "-u", "root", containerName, "rm", "-rf", path)
|
||||||
if err := rmCmd.Run(); err != nil {
|
output, err := rmCmd.CombinedOutput()
|
||||||
return fmt.Errorf("error removing path: %v", err)
|
if err != nil {
|
||||||
|
return fmt.Errorf("error removing path: %v, output: %s", err, output)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// func savePipelineData(pipelineId, identifier, status string) error {
|
// func savePipelineData(pipelineId, identifier, status string) error {
|
||||||
|
|
||||||
// url := fmt.Sprintf("%s/api/v1/triggers/pipeline/save", baseUrl)
|
// url := fmt.Sprintf("%s/api/v1/triggers/pipeline/save", baseUrl)
|
||||||
|
|||||||
Reference in New Issue
Block a user