{"record":{"id":"bdd1ffa6f741f5c6","repo":"shadow1ng/fscan","slug":"unsupported-platform","errorCode":null,"errorMessage":"unsupported_platform","messagePattern":"unsupported_platform","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"plugins/local/systemdservice.go","lineNumber":45,"sourceCode":"\n// NewSystemdServicePlugin 创建系统服务持久化插件\nfunc NewSystemdServicePlugin() *SystemdServicePlugin {\n\treturn &SystemdServicePlugin{\n\t\tBasePlugin: plugins.NewBasePlugin(\"systemdservice\"),\n\t}\n}\n\n// Scan 执行系统服务持久化 - 直接实现\nfunc (p *SystemdServicePlugin) Scan(ctx context.Context, info *common.HostInfo, session *common.ScanSession) *plugins.Result {\n\tconfig := session.Config\n\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{","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/local/systemdservice.go#L27-L63","documentation":"Guard in SystemdServicePlugin.Scan: the plugin's persistence technique (creating systemd services) only works on Linux, but runtime.GOOS reported a different platform. The scan aborts before touching the filesystem and reports the unsupported OS alongside the linux-only notice.","triggerScenarios":"Calling the systemd service plugin's Scan on Windows, macOS, or any GOOS != \"linux\".","commonSituations":"Running the local persistence/audit plugin suite on a macOS developer laptop or a Windows host without gating Linux-only plugins.","solutions":["Only register/invoke the systemd plugin on Linux hosts","Gate the call with runtime.GOOS == \"linux\" before invoking Scan","If you need equivalent functionality elsewhere, use launchd (macOS) or Windows services plugins instead"],"exampleFix":"// before\nres := systemdPlugin.Scan(cfg)\n// after\nif runtime.GOOS != \"linux\" {\n    return // skip Linux-only plugin\n}\nres := systemdPlugin.Scan(cfg)","handlingStrategy":"type-guard","validationCode":"if runtime.GOOS != \"linux\" {\n    // skip systemd plugin\n}","typeGuard":"func isLinux() bool { return runtime.GOOS == \"linux\" }","tryCatchPattern":null,"preventionTips":["Gate Linux-only plugins by runtime.GOOS before registration","Keep OS-specific plugins behind build tags","Test plugin suites on each target OS"],"tags":["platform","linux","systemd","portability"],"backgroundTag":"unsupported-platform","analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}