falcosecurity/falco-lsp

GitHub: falcosecurity/falco-lsp

Falco 规则的 LSP 实现与 VS Code 扩展,为安全规则开发提供智能补全、语法校验和格式化等编辑器增强功能。

Stars: 4 | Forks: 1

# Falco 规则语言工具 - Language Server、CLI 和 VS Code 扩展

Falco Rules

[![Falco 生态仓库](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/19ee96726b195827.svg)](https://github.com/falcosecurity/evolution/blob/main/REPOSITORIES.md#ecosystem-scope) [![孵化中](https://img.shields.io/badge/status-incubating-orange?style=for-the-badge)](https://github.com/falcosecurity/evolution/blob/main/REPOSITORIES.md#incubating) [![许可证](https://img.shields.io/github/license/falcosecurity/falco-lsp?style=for-the-badge)](./LICENSE) [![最新版本](https://img.shields.io/github/v/release/falcosecurity/falco-lsp?style=for-the-badge)](https://github.com/falcosecurity/falco-lsp/releases/latest) ## 概述 本仓库为 [Falco](https://falco.org) 安全规则提供全面的语言工具支持: - **Language Server (LSP)** - 与编辑器无关的智能支持,提供实时验证 - **CLI 工具** - 通过命令行进行验证和格式化 - **VS Code 扩展** - 丰富的 IDE 体验,包括语法高亮、自动补全和诊断 - **完整的 YAML 支持** - 100% 兼容现有的 `.yaml`/`.yml` Falco 规则 ## 功能特性 - ✅ **实时验证** - 在输入时检测语法和语义错误 - ✅ **智能补全** - 针对字段、宏和列表的上下文感知建议 - ✅ **转到定义** - 跳转到宏和列表的定义位置 - ✅ **悬停信息** - 字段文档和宏/列表预览 - ✅ **语法高亮** - 对条件和规则结构进行精确高亮 - ✅ **跨平台** - 支持 Linux、macOS 和 Windows ## 架构 ``` ┌──────────────────────────────────────────────────────────────┐ │ CONSUMERS │ ├─────────────────┬──────────────────┬────────────────────────┤ │ VS Code │ CLI Tool │ Other Editors │ │ Extension │ │ (Neovim, etc.) │ └────────┬────────┴────────┬─────────┴───────────┬────────────┘ │ │ │ └─────────────────┴─────────────────────┘ │ ┌─────────────▼─────────────┐ │ Go Language Server │ │ ┌─────────────────────┐ │ │ │ YAML Parser │ │ │ ├─────────────────────┤ │ │ │ Condition Parser │ │ │ ├─────────────────────┤ │ │ │ Semantic Analyzer │ │ │ ├─────────────────────┤ │ │ │ LSP Protocol │ │ │ └─────────────────────┘ │ └───────────────────────────┘ ``` ## 快速开始 ### VS Code 扩展 从 VS Code Marketplace 安装: 1. 打开 VS Code 2. 转到扩展 (Ctrl+Shift+X) 3. 搜索 "Falco Rules" 4. 点击安装 或者通过命令行: ``` code --install-extension falcosecurity.falco-rules ``` ### CLI 工具 #### 从源码构建 ``` # 克隆 repository git clone https://github.com/falcosecurity/falco-lsp.git cd falco-lsp/falco-lsp # Build make build # 或者手动 go build -o build/falco-lang ./cmd/falco-lang # 安装到 GOPATH make install ``` #### 使用方法 ``` # 验证 Falco rules falco-lang validate ./rules/ # 验证特定文件 falco-lang validate file1.yaml file2.yaml # 格式化 rules(检查模式) falco-lang format ./rules/ # 格式化 rules(就地写入) falco-lang format --write ./rules/ ``` ## 项目结构 ``` ├── falco-lsp/ # Language Server (Go) │ ├── cmd/falco-lang/ # CLI entry point │ ├── internal/ │ │ ├── analyzer/ # Semantic analysis │ │ ├── ast/ # AST definitions │ │ ├── condition/ # Condition expression parser │ │ ├── fields/ # Falco field definitions │ │ ├── lexer/ # Tokenizer │ │ ├── lsp/ # Language Server Protocol │ │ └── parser/ # YAML rule parser │ ├── Makefile # Build system │ └── README.md ├── vscode-extension/ # VS Code Extension (TypeScript) │ ├── src/ # Extension source code │ ├── schemas/ # JSON schemas │ ├── syntaxes/ # TextMate grammars │ ├── snippets/ # Code snippets │ ├── scripts/ # Sync scripts │ └── package.json ├── examples/ # Example Falco rules └── schema/ # Shared JSON schemas ``` ## 支持的 Falco 结构 ### 规则 ``` - rule: Detect Shell in Container desc: Detects when a shell is spawned inside a container condition: spawned_process and container and proc.name in (shell_binaries) output: "Shell spawned in container (user=%user.name container=%container.name)" priority: WARNING tags: [container, shell, mitre_execution] ``` ### 宏 ``` - macro: container condition: container.id != host - macro: spawned_process condition: evt.type in (execve, execveat) and evt.dir = < ``` ### 列表 ``` - list: shell_binaries items: [bash, sh, zsh, dash, csh, tcsh, ksh, ash] ``` ## 开发 ### 构建 ``` # Build Go language server cd falco-lsp make build # 运行测试 make test # Build VS Code extension cd vscode-extension npm install && npm run build ``` ## 贡献 欢迎贡献代码!在提交 Pull Request 之前,请阅读我们的[贡献指南](CONTRIBUTING.md)。 1. Fork 本仓库 2. 创建一个功能分支 3. 进行更改并添加测试 4. 提交 Pull Request ## 许可证 本项目采用 Apache 2.0 许可证授权 - 详见 [LICENSE](LICENSE) 文件。 ## 相关项目 - [Falco](https://github.com/falcosecurity/falco) - 云原生运行时安全 - [falcoctl](https://github.com/falcosecurity/falcoctl) - Falco 管理工具 - [Falco Rules](https://github.com/falcosecurity/rules) - 官方 Falco 规则仓库
标签:AMSI绕过, Chrome Headless, CNCF, EVTX分析, Falco, Falco规则, FTP漏洞扫描, Go语言, IDE插件, Kubernetes安全, LSP, SOC Prime, VSCode 扩展, web渗透, YAML, 云安全监控, 云计算, 代码补全, 威胁检测, 安全库, 安全编排, 开发工具, 敏感词过滤, 日志审计, 程序破解, 规则引擎, 语法高亮, 语言服务器协议, 静态分析