Skip to content

Commit 6f8e964

Browse files
committed
Remove Serapeum dependency; add (simpler) DEFALIAS macro
1 parent 65eb523 commit 6f8e964

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

cleek.asd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
:description "A Zeek log manipulation CLI tool."
1010
:author "Yacin Nadji <yacin@defmacro.cc>"
1111
:license "MIT"
12-
:depends-on ("str" "uiop" "alexandria" "cl-ppcre" "cl-tld" "netaddr" "cl-dns" "com.inuoe.jzon" "local-time" "clingon" "serapeum" "split-sequence" "cl-interpol" "ironclad")
12+
:depends-on ("str" "uiop" "alexandria" "cl-ppcre" "cl-tld" "netaddr" "cl-dns" "com.inuoe.jzon" "local-time" "clingon" "split-sequence" "cl-interpol" "ironclad")
1313
:components ((:file "packages")
1414
(:file "types")
1515
(:file "io")

helpers.lisp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,16 @@
2020
(find x container))
2121
(:method ((substring string) (x string))
2222
(str:contains? substring x)))
23-
(serapeum:defalias c? #'contains? "Alias for CONTAINS?")
2423

25-
(serapeum:defalias s= #'string= "Alias for STRING=")
26-
(serapeum:defalias s/= #'string/= "Alias for STRING/=")
24+
(defmacro defalias (alias func &optional docstring)
25+
`(progn (setf (fdefinition ',alias) ,func)
26+
(when ,docstring
27+
(setf (documentation ',alias 'function) ,docstring))))
28+
29+
(defalias c? #'contains? "Alias for CONTAINS?")
30+
31+
(defalias s= #'string= "Alias for STRING=")
32+
(defalias s/= #'string/= "Alias for STRING/=")
2733

2834
(defun f (path &optional (type :str) (max-vector-size 7))
2935
"Read in a list of TYPE data from a file, one per line, to use as a container for CONTAINS? searches. TYPE must be one of (:STR :IP :DNS). :DNS builds a CL-DNS:TRIE to check for domain membership, :IP builds a NETADDR:IP-SET for IP/CIDR membership, and :STR builds an array (or HASH-TABLE if the file contains over MAX-VECTOR-SIZE items)."
@@ -45,12 +51,12 @@
4551
(:method ((ts real))
4652
(double-to-timestamp ts)))
4753

48-
(serapeum:defalias ts< #'local-time:timestamp< "Alias for LOCAL-TIME:TIMESTAMP<")
49-
(serapeum:defalias ts<= #'local-time:timestamp<= "Alias for LOCAL-TIME:TIMESTAMP<=")
50-
(serapeum:defalias ts> #'local-time:timestamp> "Alias for LOCAL-TIME:TIMESTAMP>")
51-
(serapeum:defalias ts>= #'local-time:timestamp>= "Alias for LOCAL-TIME:TIMESTAMP>=")
52-
(serapeum:defalias ts= #'local-time:timestamp= "Alias for LOCAL-TIME:TIMESTAMP=")
53-
(serapeum:defalias ts/= #'local-time:timestamp/= "Alias for LOCAL-TIME:TIMESTAMP/=")
54+
(defalias ts< #'local-time:timestamp< "Alias for LOCAL-TIME:TIMESTAMP<")
55+
(defalias ts<= #'local-time:timestamp<= "Alias for LOCAL-TIME:TIMESTAMP<=")
56+
(defalias ts> #'local-time:timestamp> "Alias for LOCAL-TIME:TIMESTAMP>")
57+
(defalias ts>= #'local-time:timestamp>= "Alias for LOCAL-TIME:TIMESTAMP>=")
58+
(defalias ts= #'local-time:timestamp= "Alias for LOCAL-TIME:TIMESTAMP=")
59+
(defalias ts/= #'local-time:timestamp/= "Alias for LOCAL-TIME:TIMESTAMP/=")
5460

5561
(defmacro anno (field &rest containers-and-labels)
5662
"Given a column in FIELD and an even number of pair-wise containers/labels, return the label for which container contains FIELD. A default container can be specified with T. Use with SETF to create a new column based on this label, for example: (setf @orig_label (anno @o_h #.#I(\"192.168.0.0/16\") \"192.168\" \".127.52.\" \"string-contains\" \'(\"fe80::1462:3ff9:fd68:b0fc\") \"list-contains\" t \"unknown\")) creates the column ORIG_LABEL based on IP checks, a string check, a list membership check, and a default case."
@@ -117,9 +123,9 @@
117123
(let ((first-ip-anon (anonip na:first-ip)))
118124
(na:make-ip-network (format nil "~a/~a" (na:str first-ip-anon) na::mask)))))))
119125

120-
(serapeum:defalias public? #'na:public? "Alias for NETADDR:PUBLIC? which returns T if the IP address is publicly routable. Requires a NETADDR::IP-LIKE (so fully parse with @@).")
121-
(serapeum:defalias private? #'na:private? "Alias for NETADDR:PRIVATE? which returns T if the IP address is privately routable. Requires a NETADDR::IP-LIKE (so fully parse with @@).")
122-
(serapeum:defalias reserved? #'na:reserved? "Alias for NETADDR:RESERVED? which returns T if the IP address is reserved. Requires a NETADDR::IP-LIKE (so fully parse with @@).")
126+
(defalias public? #'na:public? "Alias for NETADDR:PUBLIC? which returns T if the IP address is publicly routable. Requires a NETADDR::IP-LIKE (so fully parse with @@).")
127+
(defalias private? #'na:private? "Alias for NETADDR:PRIVATE? which returns T if the IP address is privately routable. Requires a NETADDR::IP-LIKE (so fully parse with @@).")
128+
(defalias reserved? #'na:reserved? "Alias for NETADDR:RESERVED? which returns T if the IP address is reserved. Requires a NETADDR::IP-LIKE (so fully parse with @@).")
123129

124130
;; is there a reasonable way to anonymize domains?
125131

0 commit comments

Comments
 (0)