A bytecode-based virtual machine to implement scripting/filtering support in your golang project.
This release adds two new primitives to the core:
join
replace
Both these primitives have full test-coverage, and seem useful. Beyond the addition of these primitives minor changes were made to resolve warnings/failures detected by an updated release of the golangci-lint tool.
This release mostly features only internal cleanups:
go-fuzz
utility.
golangci-lint
, rather than the previous selection of tools.
There were two new featuresadded:
if
and else if
statements.
This release fixes a panic
when reflection was used against a JSON object which contained a null
value for a key. This was reported in #165, and resolved in #170.
After resolving this panic I was reminded we have the setup for running fuzz-testing so I ran the fuzzer for several hours and resolved the few parser issues it caught. (These new issues were all related to the recently added support for hash-access via the .
operator.)
Although fuzzing is always somewhat random (by design!) I've been running it for several hours without any additional problems reported which is a reassuring thing:
2021/05/15 12:20:19 workers: 1, corpus: 1885 (1m49s ago), crashers: 0, restarts: 1/9999, execs: 60544462 (4680/sec), cover: 1898, uptime: 3h35m
2021/05/15 12:20:22 workers: 1, corpus: 1885 (1m52s ago), crashers: 0, restarts: 1/10000, execs: 60560974 (4680/sec), cover: 1898, uptime: 3h35m
2021/05/15 12:20:25 workers: 1, corpus: 1885 (1m55s ago), crashers: 0, restarts: 1/9999, execs: 60577329 (4681/sec), cover: 1898, uptime: 3h35m
This release concentrates on stability and error-recovery:
evalfilter
object can now be used across goroutines
panic
will now have that reported.
These changes, combined, should improve our robustness. This release also features a new built-in function panic
which can be used to test the recovery, or terminate your scripts with a specific error-value.
This release contains a small number of changes, as well as the usual internal cleanups and reorganizations.
The following new primitives were added, and documented:
between
max
min
We can now access nested hash-values, which is particularly useful when dealing with JSON objects. This can be achieved either via foo.bar.baz
, or via the long-form which was previously supported (foo["bar"]["baz"]
).
Finally it is now possible to use the underscore (_
) character in identifiers, which is necessary if you're working upon fields with names containing that character.
Our test-coverage remains high (100% for the newly added features), and our reflection support was unified to ensure that the different kinds of input (struct vs. object) are both processed in the same manner. Some of our longer tests were broken down into smaller functions, to remove complexity but there were no real functional changes.
This release features several new features and improvements, as well as the usual collection of bugfixes, and improvements to our internal codebase.
Once more testing has been a big focus, we now have ~99% test-coverage of our virtual-machine, and significantly improved coverage of other areas in our package.
New features include:
a = { "Name": "Steve", "Alive": true }
printf("%s\n", a["Name"]);
foreach key, value in a { printf("Key %s Value %s\n", key, value ); }
return
statement.
&object.Void{}
in that case.case
/switch
statements.
The major new feature in this release is the ability to create functions inside the scripts that the engine executes. For example it is now possible to write:
// Sum the values in the provided array
function sum(array) {
local total;
total = 0;
foreach val in array {
total += val;
}
return( total );
}
printf("Sum of 1-100 is %d\n", sum(1..100));
return sum(1..100) == 5050;
In this example you can see several new things demonstrated:
function ..
block.
local
keyword. This binds the variable to the local scope.
total
.+=
.The addition of functions required many small changes throughout the codebase, and as a result of that our test-coverage was improved significantly to give confidence nothing was broken in the process. (There is still room for additional test-coverage, and that will be worked upon going forward.)
As minor features mutator-operations were added (+=
, -=
, *=
and /=
), as demonstrated above, and the keyword for
was added as a synonym for while
.
A bugfix was made to the way that evalfilter-arrays are exported to Golang values, bounds-checking was added to the runtime virtual machine to guard against panics when executing untrusted bytecode. (Executing user-provided scripts is safe, as a result of the sanity-checks and error-detection in the lexer, parser, and evaluator. It is never expected that you'll process untrusted bytecode - but adding sanity-checks is still a useful thing to do.)
Finally the new built-in function getenv
was added, allowing scripts to read the contents of environmental variables.
As a consequence of supporting user-defined functions the output of the bytecode
subcommand in the standalone evalfilter binary was altered - The standalone executable also gained support for integrated TAB-completion (for bash
).
This release makes some minor changes and improvements to our library, but nothing hugely significant:
context.Context
to implement timeouts when executing scripts.
foreach
iteration support.
Finally we've included a simple webassembly demo, which involves compiling our library to WASM and executing it in a browser. Find it beneath _examples/wasm.
This release contains a number of changes to the scripting-language available to consumers of the library, largely as a result of my use of the evalfilter-library in a simple application for scripting the manipulation of Google Gmail labels.
The language as a whole benefits from increasing usage, as it points out shortcomings that might otherwise not be apparent. In my case this largely revolved around the pain of iterating over arrays manually with a
for
-loop.
A brief summary of changes in this release:
foreach
primitive.
1..10
++
and --
operations.
return
statement
0+foreach+0()
, and !foreach%0()
.Once again this release features on minor improvements to the code structure, layout, and internal organization.
There have been new features in the release though, most notably:
field = Subject ? Subject : Title
"\
, and only valid flags are accepted/i
for ignoring-case, and /m
for multi-line matches.)sprintf
and printf
, via #101.