Skip to content

Commit

Permalink
Change: Rename nasl-cli to scannerctl
Browse files Browse the repository at this point in the history
  • Loading branch information
Kraemii committed Mar 11, 2024
1 parent 086ed83 commit e904a94
Show file tree
Hide file tree
Showing 29 changed files with 346 additions and 112 deletions.
60 changes: 30 additions & 30 deletions .docker/prod-oldstable.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,33 @@ FROM greenbone/openvas-smb:oldstable-edge AS openvas-smb
FROM greenbone/gvm-libs:${GVM_LIBS_VERSION} AS build
COPY . /source
RUN apt-get update && apt-get install --no-install-recommends --no-install-suggests -y \
bison \
build-essential \
clang \
clang-format \
clang-tools \
cmake \
curl \
lcov \
libgnutls28-dev \
libgpgme-dev \
libjson-glib-dev \
libksba-dev \
libpaho-mqtt-dev \
libpcap-dev \
libssh-gcrypt-dev \
libbsd-dev \
libgnutls30 \
libgssapi3-heimdal \
libkrb5-26-heimdal \
libasn1-8-heimdal \
libroken18-heimdal \
libhdb9-heimdal \
libpopt0 \
libcurl4-gnutls-dev \
libcurl4 \
libcgreen1-dev \
&& rm -rf /var/lib/apt/lists/*
bison \
build-essential \
clang \
clang-format \
clang-tools \
cmake \
curl \
lcov \
libgnutls28-dev \
libgpgme-dev \
libjson-glib-dev \
libksba-dev \
libpaho-mqtt-dev \
libpcap-dev \
libssh-gcrypt-dev \
libbsd-dev \
libgnutls30 \
libgssapi3-heimdal \
libkrb5-26-heimdal \
libasn1-8-heimdal \
libroken18-heimdal \
libhdb9-heimdal \
libpopt0 \
libcurl4-gnutls-dev \
libcurl4 \
libcgreen1-dev \
&& rm -rf /var/lib/apt/lists/*

COPY --from=openvas-smb /usr/local/lib/ /usr/local/lib/
RUN cmake -DCMAKE_BUILD_TYPE=Release -DINSTALL_OLD_SYNC_SCRIPT=OFF -B/build /source
Expand Down Expand Up @@ -66,15 +66,15 @@ RUN apt-get update && apt-get install --no-install-recommends --no-install-sugge
libroken18-heimdal \
libhdb9-heimdal \
libpopt0 \
libcurl4 \
libcurl4 \
zlib1g\
&& rm -rf /var/lib/apt/lists/*
COPY .docker/openvas.conf /etc/openvas/
# must be pre built within the rust dir and moved to the bin dir
# usually this image is created within in a ci ensuring that the
# binary is available.
COPY assets/$TARGETPLATFORM/nasl-cli /usr/local/bin/nasl-cli
RUN chmod +x /usr/local/bin/nasl-cli
COPY assets/$TARGETPLATFORM/scannerctl /usr/local/bin/scannerctl
RUN chmod +x /usr/local/bin/scannerctl
COPY --from=build /install/ /
COPY --from=openvas-smb /usr/local/lib/ /usr/local/lib/
COPY --from=openvas-smb /usr/local/bin/ /usr/local/bin/
Expand Down
4 changes: 2 additions & 2 deletions .docker/prod-testing.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ COPY .docker/openvas.conf /etc/openvas/
# must be pre built within the rust dir and moved to the bin dir
# usually this image is created within in a ci ensuring that the
# binary is available.
COPY assets/$TARGETPLATFORM/nasl-cli /usr/local/bin/nasl-cli
RUN chmod +x /usr/local/bin/nasl-cli
COPY assets/$TARGETPLATFORM/scannerctl /usr/local/bin/scannerctl
RUN chmod +x /usr/local/bin/scannerctl
COPY --from=build /install/ /
COPY --from=openvas-smb /usr/local/lib/ /usr/local/lib/
COPY --from=openvas-smb /usr/local/bin/ /usr/local/bin/
Expand Down
4 changes: 2 additions & 2 deletions .docker/prod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ COPY .docker/openvas.conf /etc/openvas/
# must be pre built within the rust dir and moved to the bin dir
# usually this image is created within in a ci ensuring that the
# binary is available.
COPY assets/$TARGETPLATFORM/nasl-cli /usr/local/bin/nasl-cli
COPY assets/$TARGETPLATFORM/scannerctl /usr/local/bin/scannerctl
COPY assets/$TARGETPLATFORM/openvasd /usr/local/bin/openvasd
RUN chmod +x /usr/local/bin/nasl-cli
RUN chmod +x /usr/local/bin/scannerctl
RUN chmod +x /usr/local/bin/openvasd
COPY --from=build /install/ /
COPY --from=openvas-smb /usr/local/lib/ /usr/local/lib/
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ jobs:
- name: "patch for debian stable"
working-directory: rust
run: |
find . -type f -name "nasl-cli"
patchelf --replace-needed libpcap.so.1 libpcap.so.0.8 target/aarch64-unknown-linux-gnu/release/nasl-cli
patchelf --replace-needed libpcap.so.1 libpcap.so.0.8 target/x86_64-unknown-linux-gnu/release/nasl-cli
patchelf --replace-needed libz.so libz.so.1 target/aarch64-unknown-linux-gnu/release/nasl-cli
patchelf --replace-needed libz.so libz.so.1 target/x86_64-unknown-linux-gnu/release/nasl-cli
find . -type f -name "scannerctl"
patchelf --replace-needed libpcap.so.1 libpcap.so.0.8 target/aarch64-unknown-linux-gnu/release/scannerctl
patchelf --replace-needed libpcap.so.1 libpcap.so.0.8 target/x86_64-unknown-linux-gnu/release/scannerctl
patchelf --replace-needed libz.so libz.so.1 target/aarch64-unknown-linux-gnu/release/scannerctl
patchelf --replace-needed libz.so libz.so.1 target/x86_64-unknown-linux-gnu/release/scannerctl
- run: mkdir assets/
- run: mkdir -p assets/linux/amd64
- run: mkdir -p assets/linux/arm64
- run: mv rust/target/aarch64-unknown-linux-gnu/release/openvasd assets/linux/arm64/openvasd
- run: mv rust/target/x86_64-unknown-linux-gnu/release/openvasd assets/linux/amd64/openvasd
- run: mv rust/target/aarch64-unknown-linux-gnu/release/nasl-cli assets/linux/arm64/nasl-cli
- run: mv rust/target/x86_64-unknown-linux-gnu/release/nasl-cli assets/linux/amd64/nasl-cli
- run: mv rust/target/aarch64-unknown-linux-gnu/release/scannerctl assets/linux/arm64/scannerctl
- run: mv rust/target/x86_64-unknown-linux-gnu/release/scannerctl assets/linux/amd64/scannerctl
- run: mv rust/target/aarch64-unknown-linux-gnu/release/feed-verifier assets/linux/arm64/feed-verifier
- run: mv rust/target/x86_64-unknown-linux-gnu/release/feed-verifier assets/linux/amd64/feed-verifier
- name: archive
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/functional.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ jobs:
docker.io
FEED_DIR="feed/" sh .github/prepare-feed.sh
install -m 755 assets/linux/amd64/feed-verifier /usr/local/bin/
install -m 755 assets/linux/amd64/nasl-cli /usr/local/bin/
install -m 755 assets/linux/amd64/scannerctl /usr/local/bin/
echo "db_address = tcp://redis:6379" >> /etc/openvas/openvas.conf
# TODO export as env variable
mv ./feed/* "$(openvas -s | grep plugins_folder | sed 's/plugins_folder = //')/"
- run: openvas -s
- name: verify feed syntax
run: nasl-cli syntax --quiet "$(openvas -s | grep plugins_folder | sed 's/plugins_folder = //')/"
run: scannerctl syntax --quiet "$(openvas -s | grep plugins_folder | sed 's/plugins_folder = //')/"
- name: verify feed update
run: feed-verifier || (cat /var/log/gvm/openvas.log && false)
- name: verify nasl tests
Expand Down
2 changes: 1 addition & 1 deletion doc/full_installation_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ Install openvasd:

```shell
sudo cp -rv $BUILD_DIR/openvasd/release/openvasd $INSTALL_PREFIX/bin/
sudo cp -rv $BUILD_DIR/openvasd/release/nasl-cli $INSTALL_PREFIX/bin/
sudo cp -rv $BUILD_DIR/openvasd/release/scannerctl $INSTALL_PREFIX/bin/
```

### ospd-openvas
Expand Down
46 changes: 23 additions & 23 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ members = [
"nasl-builtin-std",
"nasl-syntax",
"nasl-interpreter",
"nasl-cli",
"scannerctl",
"nasl-c-lib",
"nasl-c-lib/libgcrypt-sys",
"storage",
Expand Down
4 changes: 2 additions & 2 deletions rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Additionally for the features defined as experimental you need:

To build and create the executables

- nasl-cli
- scannerctl
- openvasd

You have to execute
Expand Down Expand Up @@ -63,7 +63,7 @@ Additionally we want to:

- do improvements in the built in function handling as we want to be more modular
- clean up the storage interface as it is very misleading currently because it enforced implementations of retrieve and dispatch.
- extend `nasl-cli` with a `openvas-nasl` like functionality so that we can test scripts
- extend `scannerctl` with a `openvas-nasl` like functionality so that we can test scripts
- implement multithreading of interpreter
- implement scheduling for a multi script run
- create an http frontend based on [OpenAPI definition](./doc/openapi.yml)
Expand Down
8 changes: 4 additions & 4 deletions rust/doc/overview.mmd
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
title: OpenVASD / nasl-cli overview
title: OpenVASD / scannerctl overview
---
erDiagram
%% mmdc -i overview.mmd -o overview.svg -b white
openvasd ||--|| feed: uses
openvasd ||--|| models: uses
openvasd ||--|| osp: uses
nasl-cli ||--|| feed : uses
nasl-cli ||--|| json-storage : uses
nasl-cli ||--|| redis-storage : uses
scannerctl ||--|| feed : uses
scannerctl ||--|| json-storage : uses
scannerctl ||--|| redis-storage : uses
feed ||--|| nasl-interpreter: uses
nasl-interpreter ||--|| nasl-builtin-std: uses
nasl-interpreter ||--|| nasl-syntax: uses
Expand Down
236 changes: 235 additions & 1 deletion rust/doc/overview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion rust/examples/error.nasl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# SPDX-License-Identifier: GPL-2.0-or-later

# when started with
# nasl-cli execute -p examples/ examples/error.nasl
# scannerctl execute -p examples/ examples/error.nasl
# it fails on include otherwise on display(a)

include("error_inc.inc");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# `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
# scannerctl -v feed transpile -p /tmp/feed -r example/replace.toml
# ```

# Transforms
Expand All @@ -27,7 +27,7 @@ FunctionByNameAndParameter = [
]

[cmds.with.Parameter.Push]
Named = [ "service_to_be", "\"world-wide-web\"", ]
Named = ["service_to_be", "\"world-wide-web\""]

# Transforms
# > register_product(cpe: ..., location: ..., port: ..., service: 'www', service_to_be: 'world-wide-web')
Expand All @@ -39,12 +39,12 @@ Named = [ "service_to_be", "\"world-wide-web\"", ]
FunctionByNameAndParameter = [
"register_product",
[
{ Name = "cpe" },
{ Name = "location" },
{ Name = "port" },
{ Name = "service" },
{ Name = "service_to_be" },
],
{ Name = "cpe" },
{ Name = "location" },
{ Name = "port" },
{ Name = "service" },
{ Name = "service_to_be" },
],
]

[cmds.with.Parameter]
Expand Down
4 changes: 2 additions & 2 deletions rust/feed-verifier/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ openvas -u
and

```
nasl-cli feed update
scannerctl feed update
```

do have the same output within redis.

This is required to verify if the rust based nasl-cli is downwards compatible to ospd-openvas.
This is required to verify if the rust based scannerctl is downwards compatible to ospd-openvas.
10 changes: 5 additions & 5 deletions rust/feed-verifier/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ fn main() {
let nasl_cli = match env::current_exe() {
Ok(mut x) => {
x.pop();
x.push("nasl-cli");
x.push("scannerctl");
x
}
Err(x) => panic!("This test program is assuming that nasl-cli is in the same dir: {x}"),
Err(x) => panic!("This test program is assuming that scannerctl is in the same dir: {x}"),
};
let (ncd, nasl_cli) = run_get(
&mut kb,
Expand All @@ -175,15 +175,15 @@ fn main() {
let mut errors = 0;
if ncd > od {
errors += print_error(&format!(
"openvas ({od:?}) was faster than nasl-cli ({ncd:?})"
"openvas ({od:?}) was faster than scannerctl ({ncd:?})"
));
}

let (left, right) = {
println!("nasl-cli: {} entries", nasl_cli.len());
println!("scannerctl: {} entries", nasl_cli.len());
println!("openvas: {} entries", openvas.len());
if nasl_cli.len() > openvas.len() {
println!("nasl-cli is left");
println!("scannerctl is left");
(nasl_cli, openvas)
} else {
println!("openvas is left");
Expand Down
2 changes: 1 addition & 1 deletion rust/notus/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use clap::{arg, value_parser, ArgAction, Command};
use notus::{loader::fs::FSProductLoader, notus::Notus};

fn main() {
let matches = Command::new("nasl-cli")
let matches = Command::new("scannerctl")
.version("1.0")
.about("Is a CLI tool around Notus.")
.arg(
Expand Down
6 changes: 3 additions & 3 deletions rust/nasl-cli/Cargo.toml → rust/scannerctl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "nasl-cli"
name = "scannerctl"
version = "0.1.0"
edition = "2021"
license = "GPL-2.0-or-later"
Expand All @@ -14,13 +14,13 @@ configparser = "3"
# recursively walk through a dir
walkdir = "2"

feed = {path = "../feed"}
feed = { path = "../feed" }
nasl-syntax = { path = "../nasl-syntax" }
models = { path = "../models" }
nasl-interpreter = { path = "../nasl-interpreter", default-features = false }
storage = { path = "../storage" }
redis-storage = { path = "../redis-storage" }
json-storage = {path = "../json-storage"}
json-storage = { path = "../json-storage" }
tracing = "0.1.37"
tracing-subscriber = { version = "0.3.17" }
serde_json = "1.0.96"
Expand Down
Loading

0 comments on commit e904a94

Please sign in to comment.