-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathvalidate.clj
55 lines (48 loc) · 1.68 KB
/
validate.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(ns burp-clj.validate
(:require [burp-clj.utils :as utils]
[clojure.tools.gitlibs :as gitlib]
[camel-snake-kebab.core :as csk]
[clojure.string :as str])
(:import [burp
IContextMenuFactory
IExtensionStateListener
IHttpListener
IIntruderPayloadGeneratorFactory
IIntruderPayloadProcessor
IMessageEditorTabFactory
IProxyListener
IScannerCheck
IScannerInsertionPointProvider
IScannerListener
IScopeChangeListener
ISessionHandlingAction
ITab]))
(defn valid-git-source?
[url]
(try (gitlib/resolve url "master")
true
(catch Exception _ false)))
(defn valid-port?
[^Integer port]
(< 0 port 65536))
(defmacro defvalid
[name class]
(let [valid-fn (-> (str "valid-" name "?")
csk/->kebab-case-symbol)]
`(defn ~valid-fn
[inst#]
(instance? ~class inst#))))
(defvalid swing-comp java.awt.Component)
(defvalid ContextMenuFactory IContextMenuFactory)
(defvalid ExtensionStateListener IExtensionStateListener)
(defvalid HttpListener IHttpListener)
(defvalid IntruderPayloadGeneratorFactory IIntruderPayloadGeneratorFactory)
(defvalid IntruderPayloadProcessor IIntruderPayloadProcessor)
(defvalid MessageEditorTabFactory IMessageEditorTabFactory)
(defvalid ProxyListener IProxyListener)
(defvalid ScannerCheck IScannerCheck)
(defvalid ScannerInsertionPointProvider IScannerInsertionPointProvider)
(defvalid ScannerListener IScannerListener)
(defvalid ScopeChangeListener IScopeChangeListener)
(defvalid SessionHandlingAction ISessionHandlingAction)
(defvalid tab ITab)