Skip to content

Commit

Permalink
Merge pull request greenbone#1717 from greenbone/single-crate
Browse files Browse the repository at this point in the history
Change rust project structure to a main crate.

Most of the previous crates are now modules of the main crate.

This PR doesn't make any functional changes.
Here is how the workspace structure changed:

    src
    crates/
        smoketest
        nasl-c-lib
        nasl-function-proc-macro

The three crates are separate for the following reasons:

    smoketest has a custom makefile. I don't know why this is necessary, but didn't want to make any functional changes, so I left it as a subcrate
    nasl-c-lib has a custom build.rs. This could be ported to be a submodule too, but since I don't know whether it will stay around, I left it as a subcrate.
    nasl-function-proc-macro needs to be a subcrate, since proc macros can not be part of the main code base.

The main crate is now called scannerlib (happy for any input on how to name it instead). This name is only used inside of the binaries (scannerctl/openvasd) to import items from the library.

The src folder looks like:

    nasl
        syntax
        interpreter
        utils
        builtin
            host
            string
            misc
            ...
    storage
        file
        json
        redis
    scanner
    scheduling
    feed
    feed_verifier
    models
    notus
    openvas
    openvasd
    osp
    plugin_scheduler
    scannerctl

There are some minor cosmetic changes besides the crate structure:

    Added a NASL prelude. This makes it easy to include the necessary items to begin writing nasl functions: use crate::nasl::prelude::*;. This automatically imports things such as NaslValue, NaslResult, Context, Register, FromNaslValue, ToNaslResult, nasl_function and function_set!.
    Added a NASL test prelude. Can be used in tests and automatically imports the TestBuilder and utility functions via use crate::nasl::test_prelude::*
    Added allow(unused) to plugin_scheduler. This wasn't previously needed but the new structure makes it apparent that this isn't currently used.
    Added allow(unused) to osp::ScanCommand::Get and removed osp::connection::get_scan which was unused.
    Moved dep_graph into plugin_scheduler module.
    For now, I moved most readme.md into their respective module and included them as a docstring for the module. We can change this in the future if we want.
    Currently, there are two crates that need two different versions simultaneously: rustls-pemfile and generic-array. I added two separate versions explicitly. We should open a ticket to update the code that requires the old one to a newer version.
  • Loading branch information
Tehforsch authored Sep 19, 2024
2 parents 900ce4b + 1f05536 commit f6e2269
Show file tree
Hide file tree
Showing 355 changed files with 2,844 additions and 4,132 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/smoketest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
kubectl rollout status --watch --timeout 600s deployment/openvasd --namespace openvasd
echo "OPENVASD_SERVER=https://$(kubectl get svc -n openvasd | awk 'FNR == 2 {print $(3)}')" >> $GITHUB_ENV
- name: smoketest
working-directory: rust/smoketest
working-directory: rust/crates/smoketest
env:
SCAN_CONFIG: configs/simple_scan_ssh_only.json
CLIENT_KEY: ../examples/tls/Self-Signed mTLS Method/client.rsa
Expand Down
Loading

0 comments on commit f6e2269

Please sign in to comment.