Token导航 LogoToken导航TokenDH.com
开发敏感数据github未标认证来源可访问许可证需确认审计提醒

frappe-syntax-whitelistedfrappe 语法已列入白名单

Agent Skill

frappe-syntax-whitelisted 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

599

周安装

24

GitHub Stars

87

下载量

194
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:frappe-syntax-whitelisted(frappe 语法已列入白名单)
来源仓库:https://github.com/openaec-foundation/erpnext_anthropic_claude_development_skill_package
仓库路径:skills/frappe-syntax-whitelisted
安装命令:
npx skills add https://github.com/openaec-foundation/erpnext_anthropic_claude_development_skill_package --skill frappe-syntax-whitelisted
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/openaec-foundation/erpnext_anthropic_claude_development_skill_package --skill frappe-syntax-whitelisted

简介

用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中围绕仓库状态或协作事项进行整理。
  • 通过 npx skills add 命令从指定仓库安装,需确认权限和维护状态。
  • 使用前建议核实是否会触发联网、命令执行或文件读写操作。
  • frappe-syntax-whitelisted 属于开发类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Frappe Syntax: Whitelisted Methods

Whitelisted methods expose Python functions as HTTP API endpoints via /api/method/.

Quick Reference

import frappe
from frappe import _

# Authenticated endpoint (default)
@frappe.whitelist()
def get_customer_summary(customer):
    frappe.has_permission("Customer", "read", throw=True)
    return frappe.get_doc("Customer", customer).as_dict()

# Public endpoint — ALWAYS validate input thoroughly
@frappe.whitelist(allow_guest=True, methods=["POST"])
def submit_contact(name, email, message):
    if not name or not email:
        frappe.throw(_("Name and email required"), frappe.ValidationError)
    return {"success": True}

# Controller method — called via frm.call('method_name')
class SalesOrder(Document):
    @frappe.whitelist()
    def calculate_taxes(self, include_shipping=False):
        return {"tax": self.grand_total * 0.21}

Endpoint URL: /api/method/myapp.module.function_name


Decorator Signature [v14+]

@frappe.whitelist(
    allow_guest=False,   # True = accessible without login
    xss_safe=False,      # True = do NOT escape HTML in response
    methods=None,        # ["GET"], ["POST"], or ["GET","POST"] — default: all
    force_types=None     # True = require type annotations [v15+]
)
ParameterDefaultEffect
allow_guestFalseTrue = Guest role can call; ALWAYS add extra input validation
xss_safeFalseTrue = HTML not escaped; NEVER use without sanitized output
methodsNone (all)Restrict allowed HTTP verbs
force_typesNoneTrue = all params MUST have type annotations [v15+]

Full details: decorator-options.md


Decision Tree

What kind of endpoint?
|
+-- Standalone API (utility, integration, dashboard)?
|   --> @frappe.whitelist() on a module-level function
|   --> Call via: frappe.call('myapp.api.function')
|   --> URL: /api/method/myapp.api.function
|
+-- Document-specific action?
|   --> @frappe.whitelist() on a Document class method
|   --> Call via: frm.call('method_name')
|   --> URL: /api/method/run_doc_method (internal)
|
+-- Server Script (no-code)?
    --> Use Server Script DocType instead (no decorator needed)

Who may call the API?
|
+-- Anyone (including guests)?
|   --> allow_guest=True + thorough input validation + rate limiting
|
+-- Logged-in users only?
    +-- Specific role? --> frappe.only_for("RoleName")
    +-- DocType-level? --> frappe.has_permission(doctype, ptype, throw=True)
    +-- Document-level? --> frappe.has_permission(doctype, ptype, doc, throw=True)

Which HTTP methods?
|
+-- Read only? --> methods=["GET"]
+-- Write only? --> methods=["POST"]
+-- Both? --> methods=["GET","POST"] or default

Permission Patterns

ALWAYS check permissions inside every whitelisted method. The @frappe.whitelist() decorator only verifies the user is logged in — it does NOT check DocType or document-level permissions.

# DocType-level permission (throw=True raises PermissionError automatically)
@frappe.whitelist()
def get_orders():
    frappe.has_permission("Sales Order", "read", throw=True)
    return frappe.get_all("Sales Order", limit=20)

# Document-level permission
@frappe.whitelist()
def get_order(name):
    frappe.has_permission("Sales Order", "read", name, throw=True)
    return frappe.get_doc("Sales Order", name).as_dict()

# Role-based restriction
@frappe.whitelist()
def admin_action():
    frappe.only_for("System Manager")  # throws if user lacks role
    return {"secret": "data"}

Full patterns: permission-patterns.md


Parameter Handling

Parameters arrive as strings from HTTP requests. ALWAYS convert explicitly.

@frappe.whitelist()
def calculate(amount, quantity, items=None):
    amount = float(amount)          # ALWAYS cast numeric params
    quantity = int(quantity)
    if isinstance(items, str):      # ALWAYS parse JSON strings
        items = frappe.parse_json(items)
    return amount * quantity

Access all request parameters via frappe.form_dict:

@frappe.whitelist()
def dynamic_handler():
    all_params = frappe.form_dict
    customer = frappe.form_dict.get("customer")

Type Annotations [v15+]

Frappe v15+ validates type annotations automatically at request time via Pydantic:

@frappe.whitelist()
def get_orders(customer: str, limit: int = 10, active: bool = True) -> dict:
    # Frappe auto-validates: limit MUST be convertible to int
    return {"orders": frappe.get_all("Sales Order", limit=limit)}

force_types and require_type_annotated_api_methods [v15+]

  • @frappe.whitelist(force_types=True) — EVERY parameter MUST have a type annotation
  • App-level enforcement via hooks.py: require_type_annotated_api_methods = 1
  • Missing annotations raise FrappeTypeError

Full details: parameter-handling.md


Client Calls

frappe.call(): Standalone APIs

// Promise-based (ALWAYS prefer this)
frappe.call({
    method: 'myapp.api.get_summary',
    args: { customer: 'CUST-001' },
    freeze: true,
    freeze_message: __('Loading...')
}).then(r => {
    console.log(r.message);  // return value is in r.message
}).catch(err => {
    frappe.show_alert({ message: __('Error'), indicator: 'red' });
});

frm.call(): Controller Methods

frm.call('calculate_taxes', { include_shipping: true })
    .then(r => frm.set_value('tax_amount', r.message.tax_amount));

REST API (External Clients)

# Token auth (ALWAYS use for external integrations)
curl -H "Authorization: token api_key:api_secret" \
     -H "Content-Type: application/json" \
     -X POST https://site.com/api/method/myapp.api.create_order \
     -d '{"customer": "CUST-001"}'

Full patterns: client-calls.md


Error Handling

@frappe.whitelist()
def process_order(order_id):
    if not order_id:
        frappe.throw(_("Order ID required"), frappe.ValidationError)

    if not frappe.has_permission("Sales Order", "write", order_id):
        frappe.throw(_("Not permitted"), frappe.PermissionError)

    try:
        result = heavy_operation(order_id)
        return {"success": True, "data": result}
    except Exception:
        frappe.log_error(frappe.get_traceback(), "process_order")
        frappe.throw(_("Operation failed. Contact support."))
ExceptionHTTP CodeWhen to Use
frappe.ValidationError417Input validation failure
frappe.PermissionError403Access denied
frappe.DoesNotExistError404Document not found
frappe.DuplicateEntryError409Duplicate record
frappe.AuthenticationError401Not logged in

Full patterns: error-handling.md


Response Patterns

# Return value auto-wraps as {"message": <return_value>}
@frappe.whitelist()
def get_data():
    return {"key": "value"}   # Client receives: {"message": {"key": "value"}}

# Custom HTTP status
@frappe.whitelist()
def create_item(data):
    doc = frappe.get_doc(data).insert()
    frappe.local.response["http_status_code"] = 201
    return {"name": doc.name}

# File download
@frappe.whitelist()
def download_report(name):
    content = generate_pdf(name)
    frappe.response.filename = f"{name}.pdf"
    frappe.response.filecontent = content
    frappe.response.type = "download"

Full patterns: response-patterns.md


Rate Limiting [v14+]

from frappe.rate_limiter import rate_limit

@frappe.whitelist(allow_guest=True)
@rate_limit(limit=5, seconds=60)  # 5 requests per 60 seconds per IP
def public_endpoint():
    return {"status": "ok"}

rate_limit signature:

rate_limit(key=None, limit=5, seconds=86400, methods="ALL", ip_based=True)

ALWAYS apply @rate_limit on allow_guest=True endpoints to prevent abuse.


Version Differences

Featurev14v15+v16+
@frappe.whitelist()YesYesYes
allow_guest, xss_safe, methodsYesYesYes
Type annotation validationNoYes (auto via Pydantic)Yes
force_types parameterNoYesYes
require_type_annotated_api_methods hookNoYesYes
@rate_limit() decoratorYesYesYes
FrappeTypeError for missing annotationsNoYesYes

Critical Rules

  1. NEVER skip permission checks@frappe.whitelist() only confirms login, not authorization
  2. NEVER use user input in raw SQL — ALWAYS use parameterized queries or ORM
  3. NEVER leak stack traces — log with frappe.log_error(), show generic messages
  4. ALWAYS validate input types — parameters arrive as strings from HTTP
  5. ALWAYS apply @rate_limit on guest endpoints — prevents abuse
  6. NEVER use ignore_permissions=True without a preceding role check
  7. ALWAYS use JSON.stringify() for complex JS args — arrays and objects

Full anti-patterns: anti-patterns.md


Security Checklist

For EVERY whitelisted method, verify:

  • Permission check present (frappe.has_permission() or frappe.only_for())
  • Input validated (types, ranges, formats)
  • SQL queries parameterized (NEVER string interpolation)
  • Error messages contain no internal details
  • allow_guest=True only with explicit reason + rate limiting
  • ignore_permissions=True only with preceding role check
  • HTTP methods restricted where possible
  • Response contains only necessary fields (no sensitive data leaks)

Reference Files

FileContent
decorator-options.mdAll @frappe.whitelist() parameters and force_types
parameter-handling.mdRequest parameters, type coercion, frappe.form_dict
response-patterns.mdReturn types, file downloads, streaming, HTTP status
client-calls.mdfrappe.call(), frm.call(), REST API, fetch patterns
permission-patterns.mdPermission checks, role guards, custom logic
error-handling.mdException types, frappe.throw(), logging
examples.mdComplete working API examples
anti-patterns.mdSecurity mistakes and performance pitfalls
hooks.mdDeclaring whitelisted methods in hooks.py
syntax.mdCore decorator syntax and registration mechanics

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.58%
按下载量换算73

Claude

29.24%
按下载量换算57

Cursor

21.5%
按下载量换算42

Gemini CLI

9.4%
按下载量换算18

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills