-
Notifications
You must be signed in to change notification settings - Fork 634
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a new feature called transpile to feed of nasl-cli. With it you can manipulate a feed, currently it is able to rename, remove, add, push parameter or functions within a feed. To demonstrate it there is an example within `examples/nasl-cli/transpile.toml` to show case - rename service `www` to `word-wide-web` in register_product - `register_host_detail` to `add_host_detail` to execute it call: ``` nasl-cli -v feed transpile -p /tmp/feed\ -r examples/nasl-cli/transpile.toml ``` Additionally to line and colum number byte ranges got added. This allows us to lookup complete statements without having to create line no lookup tables or reading twice. Usually the statements get discarded after execution so the additional memory should not be a big issue.
- Loading branch information
1 parent
6775b61
commit 51ae0a4
Showing
32 changed files
with
2,615 additions
and
1,248 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# This demo shows how to use a configuration to rename: | ||
# `www` to `world-wide-web` when in register_product the parameter cpe, location, port are set and when service is set to `www` | ||
# `register_host_detail` to `add_host_detail` | ||
# To test it get a community feed and run: | ||
# ``` | ||
# nasl-cli -v feed transpile -p /tmp/feed -r example/replace.toml | ||
# ``` | ||
|
||
[[cmds]] | ||
|
||
[cmds.find] | ||
FunctionByNameAndParameter = [ | ||
"register_product", | ||
[ | ||
{ Name = "cpe" }, | ||
{ Name = "location" }, | ||
{ Name = "port" }, | ||
{ NameValue = [ | ||
"service", | ||
"\"www\"", | ||
] }, | ||
], | ||
] | ||
|
||
[cmds.with.Parameter.Push] | ||
Named = [ | ||
"service_to_be", | ||
"\"world-wide-web\"", | ||
] | ||
|
||
[[cmds]] | ||
|
||
[cmds.find] | ||
FunctionByNameAndParameter = [ | ||
"register_product", | ||
[ | ||
{ Name = "cpe" }, | ||
{ Name = "location" }, | ||
{ Name = "port" }, | ||
{ Name = "service" }, | ||
{ Name = "service_to_be" }, | ||
], | ||
] | ||
|
||
[cmds.with.Parameter] | ||
RemoveNamed = "service" | ||
|
||
[[cmds]] | ||
|
||
[cmds.find] | ||
FunctionByName = "register_product" | ||
|
||
[cmds.with.Parameter.Rename] | ||
previous = "service_to_be" | ||
new = "service" | ||
|
||
[[cmds]] | ||
|
||
[cmds.find] | ||
FunctionByName = "register_host_detail" | ||
|
||
[cmds.with] | ||
Name = "add_host_detail" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.