Cyber Sequence
Language.
Write scripts, watch event streams, and define what happens when a rule fires.
How ranks work
The proposed Sequence system starts at 9 and ends at 0. Each step unlocks a new function set and keeps all the sets already unlocked.
Function sets
PROPOSED APISelect a Sequence to see its five new functions. These signatures describe the rank design and are pending implementation.
Quick start
From the interpreter repository, build CSL and start its interactive prompt. Enter len("CSL") to see 3.
./build.sh
./runTo run a file, use ./run path/to/script.csl. Save this example as score.csl to try a function call.
fun withBonus(points) {
if (points >= 3) return points + 2;
return points;
}
print withBonus(3); // 5Script basics
- Values
- Numbers, double-quoted strings, booleans,
nil, and functions. Onlyfalseandnilare falsey. - Variables
- Declare with
var score = 0;and assign withscore = 5;. Braces create a local scope. - Operators
- Use
+ - * /for arithmetic, comparisons such as>=, and!,and, andorfor logic.+also joins strings. - Control flow
- Use
if,else,while, andfor. Use//for line comments. - Functions
- Declare with
fun. A function can close over variables in its enclosing scope. A barereturn;or reaching the end yieldsnil. - Built-ins
len(text)counts Unicode code points.typeOf(value)returns"number","string","boolean","nil", or"function". These are ordinary script functions outside the rank system.
Watches & abilities
A watch selects a source, counts matching events within a rolling window, and runs a sequence when the count reaches the threshold.
watch failedSignIns {
source "signins";
count "failed_signin" by "account" within 60 >= 3;
sequence {
alert "Review repeated sign-in failures";
}
}This rule alerts when an account reaches three failures within 60 seconds. Each account has a separate count. A rule can fire again after old events expire and the count crosses the threshold again.
./run examples/failed-signins.csl < examples/signins.jsonlWatch files read one JSON object per input line. Send integer timestamps in seconds, in nondecreasing order per source, and put group values in the fields object. With a single named source, events may omit source.
{"source":"signins","kind":"failed_signin","timestamp":40,"fields":{"account":"ana"}}Reuse a sequence
Declare a named ability and use sequence summarizeSignIns; in a watch to call it. Ability steps run in the order you write them.
ability summarizeSignIns {
target "local-report";
require capability "report:review";
sequence {
inspect;
alert "Review repeated sign-in failures";
}
}
watch failedSignIns {
source "signins";
count "failed_signin" by "account" within 60 >= 3;
sequence summarizeSignIns;
}Capability grants
CSL checks the target and required capability when the watch program starts. To run the ability above, save the file and pass a grant for its target and capability.
./run review-signins.csl --grant local-report report:review < examples/signins.jsonlIn the proposed rank system, the rank unlocks an operation and the host grant authorizes it for a specific target. The current ability syntax uses inspect; for a summary and emits simulated intent records for isolate; and execute;.