LispIsh Documentation - Gerrit0/CTFd_unique_challenges GitHub Wiki
LispIsh is a minimal lisp like language used for sandboxed evaluation of advanced challenge requirements.
(and
(<=
(user-score)
1)
(/=
(user-name)
"gerrit"))
Since LispIsh is built on top of Python, 0
is falsy and any other number is truthy. Unlike Python, function names are case-insensitive. (AND 1 2)
is equivalent to (and 1 2)
. However, string comparison is case sensitive. (= "a" "A")
is false.
The advanced requirements editor allows administrators to insert a function call that will be evaluated to determine if the user can access the given challenge.
The following builtin functions exist:
Function | Arguments | Description |
---|---|---|
= |
2+ | Checks if all arguments are equal, (= 1 2) is false while (= 1 1) is true. |
/= |
2+ | Checks if all arguments are distinct, (/= 1 2) is true, while (/= 1 2 2) is false. |
and |
0+ | False if any arguments are falsy, otherwise true. |
or |
0+ | True if at least one argument is truthy, otherwise false. |
not |
1 | Inverts the truthiness of the argument. (not 1) is false, (not 0) is true. |
+ |
0+ | Sums the arguments, if no arguments are provided produces 0. (add 1 2 3) is 6 . |
- |
1+ | Starts with the first argument, and subtracts each argument after it from the initial value. (sub 4 1 2) is 1 . If only one argument is provided, returns the negation of it. (- 1) is equivalent to (- 0 1) . |
max |
1+ | Returns the maximum of the arguments, (max 1 2) is 2 . |
min |
1+ | Returns the minimum of the arguments, (min 1 2) is 1 . |
> |
2+ | Checks if each argument provided is greater than the argument following it. (> 1 2) is false because 1 > 2 is false. (> 3 2 1) is true because 3 > 2 and 2 > 1 . |
>= |
2+ | Checks if each argument provided is greater than or equal to the argument following it. (>= 1 1) is true, while (>= 1 2) is false. |
< |
2+ | Checks if each argument provided is less than the argument following it. (< 1 2) is true, while (< 2 1) is false. |
<= |
2+ | Checks if each argument provided is less than or equal to the argument following it. (<= 0 1 1) is true, while (<= 2 1) is false. |
In addition to the default language functions, the advanced requirements page provides some helper functions for querying challenge info.
Function | Arguments | Description |
---|---|---|
completed |
0+ | For each argument, if it is an integer, look up the challenge with that ID. If the argument is a string, look up the challenge having that name. If any of the challenges have not been completed, returns false. Otherwise, returns true. |
cohort |
0+ | True if the current user is in all of the specified cohorts, behaves the same as completed for cohorts instead of challenges. |
before |
1 | Returns true if the current time is before the given time. Time may be specified as an integer, which will be treated as the epoch time, or as a string with format YYYY-MM-DD or YYYY-MM-DD HH:MM. |
after |
1 | Logical inverse of before . |
user-email |
0 | Returns the current user's email. |
user-name |
0 | Returns the current user's name. Note: Names are not necessarily unique. |
user-id |
0 | Returns the current user's ID. |
user-score |
0 | Returns the current user's overall score from completing challenges and receiving awards. |