{"record":{"id":"cc5a4bd2ed7ba536","repo":"shadow1ng/fscan","slug":"unsupported-platform-arg1","errorCode":null,"errorMessage":"Unsupported platform: {{.Arg1}}","messagePattern":"Unsupported platform: (.+?)\\}","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/local/crontask.go","lineNumber":46,"sourceCode":"}\n\n// NewCronTaskPlugin 创建计划任务持久化插件\nfunc NewCronTaskPlugin() *CronTaskPlugin {\n\treturn &CronTaskPlugin{\n\t\tBasePlugin: plugins.NewBasePlugin(\"crontask\"),\n\t}\n}\n\n// Scan 执行计划任务持久化 - 直接实现\nfunc (p *CronTaskPlugin) 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\treturn &plugins.Result{\n\t\t\tSuccess: false,\n\t\t\tOutput:  i18n.GetText(\"crontask_linux_only\"),\n\t\t\tError:   fmt.Errorf(\"%s\", i18n.Tr(\"unsupported_platform\", runtime.GOOS)),\n\t\t}\n\t}\n\n\t// 从config获取配置\n\tp.targetFile = config.PersistenceTargetFile\n\tif p.targetFile == \"\" {\n\t\treturn &plugins.Result{\n\t\t\tSuccess: false,\n\t\t\tOutput:  i18n.GetText(\"persistence_file_required\"),\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(p.targetFile); os.IsNotExist(err) {\n\t\treturn &plugins.Result{\n\t\t\tSuccess: false,\n\t\t\tOutput:  i18n.Tr(\"target_file_not_exist\", p.targetFile),","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/local/crontask.go#L28-L64","documentation":"The crontask persistence plugin only supports Linux: it manipulates system cron files that do not exist in the same form on other operating systems. When Scan runs with runtime.GOOS != \"linux\", it returns a failed Result whose Error is built from the localized unsupported_platform template (rendered with the current OS). No system changes are made.","triggerScenarios":"Running the crontask plugin's Scan on darwin or windows (any non-Linux GOOS).","commonSituations":"Testing the persistence plugin locally on macOS during development; deploying an agent build to Windows servers; cross-platform test suites that exercise all plugins on the host OS.","solutions":["Run the crontask plugin only on Linux hosts (or in a Linux container).","Gate the plugin in your task scheduler with a runtime.GOOS == \"linux\" check and skip it elsewhere.","Use an OS-appropriate persistence mechanism on other platforms instead of this plugin.","Treat the failed Result (Success=false) as an expected skip, not a crash, in orchestration code."],"exampleFix":"// before\nresult := crontaskPlugin.Scan(ctx, cfg)\n// after\nif runtime.GOOS != \"linux\" {\n    return nil // plugin unsupported here\n}\nresult := crontaskPlugin.Scan(ctx, cfg)","handlingStrategy":"fallback","validationCode":"if runtime.GOOS != \"linux\" {\n    return nil // skip crontask plugin\n}","typeGuard":"func crontaskSupported() bool { return runtime.GOOS == \"linux\" }","tryCatchPattern":"res := plugin.Scan(ctx, cfg)\nif !res.Success && strings.Contains(res.Error.Error(), \"Unsupported platform\") {\n    log.Println(\"crontask skipped: unsupported OS\")\n    return nil\n}","preventionTips":["Maintain a per-plugin OS support matrix and consult it in schedulers.","Run plugin tests inside Linux containers for this plugin.","Expect failed Results (not panics) for platform-skips and handle them."],"tags":["persistence","cross-platform","cron"],"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"}