{"record":{"id":"a035b5f2e10e9639","repo":"shadow1ng/fscan","slug":"target-file-not-specified-a035b5","errorCode":null,"errorMessage":"target_file_not_specified","messagePattern":"target_file_not_specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/local/systemdservice.go","lineNumber":56,"sourceCode":"\tvar output strings.Builder\n\n\tif runtime.GOOS != \"linux\" {\n\t\toutput.WriteString(i18n.GetText(\"systemdservice_linux_only\") + \"\\n\")\n\t\treturn &plugins.Result{\n\t\t\tSuccess: false,\n\t\t\tOutput:  output.String(),\n\t\t\tError:   fmt.Errorf(\"%s\", i18n.Tr(\"unsupported_platform\", runtime.GOOS)),\n\t\t}\n\t}\n\n\t// 从config获取配置\n\ttargetFile := config.PersistenceTargetFile\n\tif targetFile == \"\" {\n\t\toutput.WriteString(i18n.GetText(\"persistence_file_required\") + \"\\n\")\n\t\treturn &plugins.Result{\n\t\t\tSuccess: false,\n\t\t\tOutput:  output.String(),\n\t\t\tError:   fmt.Errorf(\"%s\", i18n.GetText(\"target_file_not_specified\")),\n\t\t}\n\t}\n\n\t// 检查目标文件是否存在\n\tif _, err := os.Stat(targetFile); os.IsNotExist(err) {\n\t\toutput.WriteString(i18n.Tr(\"target_file_not_exist\", targetFile) + \"\\n\")\n\t\treturn &plugins.Result{\n\t\t\tSuccess: false,\n\t\t\tOutput:  output.String(),\n\t\t\tError:   err,\n\t\t}\n\t}\n\n\t// 检查systemctl是否可用\n\tif _, err := exec.LookPath(\"systemctl\"); err != nil {\n\t\toutput.WriteString(i18n.Tr(\"systemctl_unavailable\", err) + \"\\n\")\n\t\treturn &plugins.Result{\n\t\t\tSuccess: false,","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/local/systemdservice.go#L38-L74","documentation":"Guard in SystemdServicePlugin.Scan: the required config.PersistenceTargetFile is empty, so there is no service file path to create or hijack. The scan cannot proceed and returns a failed result naming the missing configuration key.","triggerScenarios":"Calling Scan with a Config whose PersistenceTargetFile is the empty string.","commonSituations":"Config struct initialized with zero values and the required path never set; YAML/JSON config missing the persistence target key; user forgot to point at the executable to persist.","solutions":["Set config.PersistenceTargetFile to the absolute path of the file to manage","Check the config file/template for the corresponding key and populate it","Add early config validation so missing required fields are rejected before plugin execution"],"exampleFix":"// before\ncfg := plugins.Config{} // PersistenceTargetFile empty\nres := p.Scan(cfg)\n// after\ncfg := plugins.Config{PersistenceTargetFile: \"/opt/myapp/myapp\"}\nres := p.Scan(cfg)","handlingStrategy":"validation","validationCode":"if cfg.PersistenceTargetFile == \"\" {\n    return errors.New(\"PersistenceTargetFile must be set\")\n}\nif _, err := os.Stat(cfg.PersistenceTargetFile); err != nil {\n    return fmt.Errorf(\"target file check: %w\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set PersistenceTargetFile in config","Validate required config fields before invoking plugins","Use absolute paths for the target file"],"tags":["config","systemd","validation","missing-field"],"backgroundTag":"missing-required-config-field","analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}