Skip to content
KitploitKITPLOIT
उपकरणब्लॉग
जमा करें
उपकरणब्लॉग
जमा करें

हैकिंग, पेनटेस्ट और साइबर सुरक्षा उपकरण आपके सुरक्षा शस्त्रागार के लिए!

Kitploit हैकिंग, साइबर सुरक्षा और पेंटेस्टिंग टूल्स की एक निर्देशिका है। कमजोरियों को खोजने, सिस्टम का विश्लेषण करने, परीक्षण को स्वचालित करने और अपनी सुरक्षा को मजबूत करने के लिए नवीनतम प्रोजेक्ट अपडेट खोजें।

··फ़ीड·संपर्क·गोपनीयता·© 2026 Kitploit

टूल निर्देशिका

श्रेणियाँ

सभी श्रेणियाँ देखें
Loading categories
kit-policy — Kit के लिए एक लचीला, संयोजनीय प्राधिकरण ढांचा (Action Policy से प्रेरित) | Kitploit
उपकरण/GitLabGitLab/kit-lang/packages/kit-policy
प्रमाणीकरण और प्राधिकरणउपयोगिताएँ और फ्रेमवर्क
GitLabkit-lang/packages/kit-policy

kit-policy

Kit के लिए एक लचीला, संयोजनीय प्राधिकरण ढांचा (Action Policy से प्रेरित)

रिपॉजिटरी देखें
1 महीना पहलेअभी तक समीक्षित नहीं

सबसे लोकप्रिय

सभी देखें →

हमारे समुदाय द्वारा सबसे अधिक उपयोग किए जाने वाले उपकरण खोजें।

सभी उपकरण खोजें

हमारे उपकरणों का संग्रह ब्राउज़ करें

सभी उपकरण देखें →
साझा करें

kit-policy (किट-पॉलिसी)

Kit के लिए एक लचीला, रचना योग्य प्राधिकरण ढांचा, Ruby के Action Policy से प्रेरित।


[TOC]


फ़ाइलें

फ़ाइलविवरण
.editorconfigसंपादक स्वरूपण कॉन्फ़िगरेशन
.gitignoreबिल्ड आर्टिफैक्ट और निर्भरताओं के लिए Git इग्नोर नियम
.tool-versionsasdf टूल संस्करण (Zig, Kit)
LICENSEMIT लाइसेंस फ़ाइल
README.mdयह फ़ाइल
examples/blog-policy.kitब्लॉग प्राधिकरण उदाहरण
kit.tomlमेटाडेटा, कार्य और लिंट कॉन्फ़िगरेशन के साथ पैकेज मैनिफेस्ट
src/core.kitकोर प्राधिकरण सहायक
src/error.kitप्राधिकरण त्रुटियाँ, परिणाम प्रकार और विफलता कारण
src/main.kitपैकेज रूट मॉड्यूल
src/scope.kitस्कोप, विधेय और पृष्ठांकन सहायक
tests/policy.test.kitएंड-टू-एंड पॉलिसी व्यवहार परीक्षण

निर्भरताएँ

कोई Kit पैकेज निर्भरता नहीं।

स्थापना

root@kitploit:~
kit add gitlab.com/kit-lang/packages/kit-policy.git

उपयोग

root@kitploit:~
import Kit.Policy.Core as PolicyCore
import Kit.Policy.Error as PolicyError
import Kit.Policy.Scope as PolicyScope

type Post = {id: Int, author-id: Int, published?: Bool, title: String}
type User = {id: Int, admin?: Bool}
type AuthContext = {user: User}

post-policy = fn(post, ctx, action) =>
  if ctx.user.admin? then
    PolicyCore.allow
  else
    match PolicyCore.resolve-alias action
      | :show -> PolicyCore.allow-if post.published?
      | :update -> PolicyCore.allow-if (ctx.user.id == post.author-id)
      | :destroy -> PolicyCore.allow-if (ctx.user.id == post.author-id)
      | _ -> PolicyCore.no-rule action

post-scope = fn(posts, ctx) =>
  if ctx.user.admin? then
    posts
  else
    posts |>> List.filter (fn(post) => post.published?)

main = fn =>
  user = {id: 1, admin?: false}
  ctx = {user: user}
  post = {id: 1, author-id: 1, published?: true, title: "Hello"}
  posts = [post]

  if PolicyCore.can-with? post-policy post ctx :update then
    println "Can update post"
  else
    println "Cannot update post"

  visible-posts = PolicyScope.scope-with post-scope posts ctx
  page = PolicyScope.paginate 1 10 visible-posts
  info = PolicyScope.pagination-info 1 10 visible-posts

  println "Visible posts: ${page}"
  println "Pages: ${info.pages}"

  err = PolicyError.not-authorized "Post" :update "not the author"
  println (PolicyError.message err)

main

API अवलोकन

Policy.Core

पॉलिसी फ़ंक्शन के लिए कोर सहायक जो Result Bool PolicyError लौटाते हैं।

root@kitploit:~
PolicyCore.can-with? policy resource context action
PolicyCore.may-with? policy resource context action

PolicyCore.allow
PolicyCore.deny
PolicyCore.allow-if condition
PolicyCore.deny-if condition
PolicyCore.no-rule action
PolicyCore.allow-or-deny condition resource-name reason action

पूर्व-जाँच सहायक Option Bool लौटाते हैं: Some true अनुमति देता है, Some false अस्वीकार करता है, और None मुख्य नियम पर जारी रहता है।

root@kitploit:~
PolicyCore.admin-bypass is-admin? ctx
PolicyCore.owner-check is-owner? resource ctx
PolicyCore.first-pre-check [check1, check2, check3]

कार्य सहायक सामान्य कार्य समूह और उपनाम प्रदान करते हैं।

root@kitploit:~
PolicyCore.crud-actions
PolicyCore.read-actions
PolicyCore.write-actions

PolicyCore.read-action? action
PolicyCore.write-action? action

PolicyCore.resolve-alias :new     # :create
PolicyCore.resolve-alias :edit    # :update
PolicyCore.resolve-alias :delete  # :destroy
PolicyCore.resolve-alias :view    # :show

पॉलिसी रचना सहायक कई प्राधिकरण परिणामों को जोड़ते हैं।

root@kitploit:~
PolicyCore.all-allowed? [result1, result2, result3]
PolicyCore.any-allowed? [result1, result2, result3]

Policy.Scope

स्कोप सहायक कॉलर को डेटा लौटाने से पहले संग्रह फ़िल्टर करते हैं।

root@kitploit:~
PolicyScope.scope-with scope-fn items ctx
PolicyScope.filter-by predicate items

PolicyScope.is-owned-by? get-owner-id get-user-id item ctx
PolicyScope.is-published? get-published item
PolicyScope.is-in-state? get-state target-state item
PolicyScope.is-admin-or? check-admin fallback-check ctx item

विधेय संयोजक पुन: प्रयोज्य स्कोप जाँच बनाने के लिए उपयोगी हैं।

root@kitploit:~
PolicyScope.both? pred1 pred2 item
PolicyScope.either? pred1 pred2 item
PolicyScope.not-matching? pred item

पृष्ठांकन सहायक 1-आधारित हैं।

root@kitploit:~
page1 = PolicyScope.paginate 1 10 items
pages = PolicyScope.total-pages 10 items
info = PolicyScope.pagination-info 1 10 items

Policy.Error

प्राधिकरण विफलताओं के लिए त्रुटि और परिणाम प्रकार।

root@kitploit:~
type PolicyError =
  | NotAuthorized {resource: String, action: Keyword, reason: String}
  | RuleNotFound {action: Keyword}
  | ContextMissing {field: String}
  | PolicyNotFound {resource-type: String}
  | CustomError String

type FailureReason = FailureReason {
  policy: String,
  action: Keyword,
  details: String
}

type AuthResult =
  | Allowed
  | Denied String

सहायक फ़ंक्शन मॉड्यूल से निर्यात किए जाते हैं, इसलिए जब PolicyError के रूप में आयात किया जाता है, तो उन्हें मॉड्यूल फ़ंक्शन के रूप में कॉल किया जाता है।

root@kitploit:~
PolicyError.not-authorized resource action reason
PolicyError.rule-not-found action
PolicyError.context-missing field
PolicyError.policy-not-found resource-type
PolicyError.custom message

PolicyError.message err
PolicyError.kind err
PolicyError.is-not-authorized? err
PolicyError.is-rule-not-found? err

PolicyError.new policy action
PolicyError.with-details policy action details
PolicyError.policy reason
PolicyError.action reason
PolicyError.details reason
PolicyError.format reason

PolicyError.allowed
PolicyError.denied reason
PolicyError.is-allowed? result
PolicyError.is-denied? result
PolicyError.reason result
PolicyError.to-result resource-name action result

डिज़ाइन नोट्स

  • पॉलिसियाँ साधारण फ़ंक्शन हैं, इसलिए उनका परीक्षण और रचना करना आसान है।
  • प्राधिकरण स्पष्ट है: सहायक अपवाद फेंकने के बजाय Result Bool PolicyError लौटाते हैं।
  • स्कोप पॉलिसी जाँच से अलग हैं ताकि प्रस्तुति या क्रमांकन से पहले सूची फ़िल्टरिंग हो सके।
  • सामान्य कार्य :index, :show, :create, :update, और :destroy जैसे कीवर्ड का उपयोग करते हैं।
  • पैकेज फ्रेमवर्क-अज्ञेयवादी है और किसी भी Kit अनुप्रयोग कोड के साथ उपयोग किया जा सकता है।

विकास

उदाहरण चलाना

ब्लॉग पॉलिसी उदाहरण को इंटरप्रेटर के साथ चलाएँ:

root@kitploit:~
kit run examples/blog-policy.kit

उदाहरण को नेटिव बाइनरी में संकलित करें:

root@kitploit:~
kit build examples/blog-policy.kit && ./blog-policy

परीक्षण चलाना

परीक्षण सूट चलाएँ:

root@kitploit:~
kit test

कवरेज के साथ परीक्षण सूट चलाएँ:

root@kitploit:~
kit test --coverage

kit dev चलाना

मानक विकास कार्यप्रवाह चलाएँ (फ़ॉर्मेट, जाँच, परीक्षण):

root@kitploit:~
kit dev

यह:

  1. src/ में स्रोत फ़ाइलों को फ़ॉर्मेट और जाँच करेगा
  2. examples/ में उदाहरणों का प्रकार जाँच करेगा
  3. कवरेज के साथ tests/ में परीक्षण चलाएगा

इंटरप्रेटर/कंपाइलर समता जाँचना

उदाहरणों के लिए समता जाँच चलाएँ:

root@kitploit:~
kit parity --failures-only

दस्तावेज़ीकरण उत्पन्न करना

डॉक टिप्पणियों से API दस्तावेज़ीकरण उत्पन्न करें:

root@kitploit:~
kit doc

नोट: डॉक टिप्पणियों (##) वाले Kit स्रोत docs/*.html में HTML दस्तावेज़ उत्पन्न करेंगे।

बिल्ड आर्टिफैक्ट साफ़ करना

उत्पन्न फ़ाइलें, कैश और बिल्ड आर्टिफैक्ट हटाएँ:

root@kitploit:~
kit task clean

नोट: kit.toml में परिभाषित।

स्थानीय स्थापना

विकास के लिए इस पैकेज को स्थानीय रूप से स्थापित करने हेतु:

root@kitploit:~
kit install

यह पैकेज को ~/.kit/packages/@kit/policy/ पर स्थापित करता है, जिससे अन्य परियोजनाओं में Kit.Policy के रूप में आयात उपलब्ध होता है।

लाइसेंस

यह पैकेज MIT लाइसेंस के अंतर्गत जारी किया गया है - विवरण के लिए LICENSE देखें।

टूल डाउनलोड करें
tests/types.test.kit
पॉलिसी प्रकार और सहायक परीक्षण