generated from falcosecurity/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wip: Merge into main
the declarative testing feature (cmd to be renamed to suite
)
#273
Open
leogr
wants to merge
145
commits into
main
Choose a base branch
from
declarative-testing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Add generic field definition to abstract referencing of steps fields, as well as fields assignment. Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Add base system call step definition to enable code reuse for specific system call steps implementation. Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
Introduce `--description-dir` flag to allow users to specify one directory paths containing YAML test description files. The directories are not loaded recursively, and only .yaml files are taken into account. Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
Add test cases support by providing the capability to specify template parameters in tests description. A template parameter is specified using the syntax %{item.<keyName>} in place of a concrete value. A test description allows to specify test case specifications using the `cases` keyword. A test case specification can use one the two supported strategy: `vector` and `matrix`. The values provided in a test case spec are interpreted differently based on the strategy employed: - if the strategy is set to `vector`, values are simply used to fill template parameters matching the corresponding value keys - if the strategy is set to `matrix`, values for each key must be lists; combinations of all lists values are used to generate a number of test cases equal to the product of the cardinalities of all lists A test template is not instantiated if it doesn't specify any case. All case specifications in a test must specify the same set of value keys. Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
Switch to incremental backoff for report retrieval and move report retrieval and printing logic out of `runTestSuite`. Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: leogr The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
mail
the declarative testing feature (cmd to be renamed to suite
)main
the declarative testing feature (cmd to be renamed to suite
)
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
314318c
to
ee1d727
Compare
main
the declarative testing feature (cmd to be renamed to suite
)main
the declarative testing feature (cmd to be renamed to suite
)
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
/kind cleanup
/kind tests
/kind feature
Any specific area of the project related to this PR?
/area commands
/area pkg
What this PR does / why we need it:
This PR merges the effort in the declarative-testing branch into the main branch. At a high level, it introduces the capability to generate suspicious actions by providing a YAML-formatted declarative description of them.
The PR introduces three commands under the
declarative
namespace (temporary solution to avoid overlapping with the already existing commands):The
test
command is a superset of therun
command: besides performing the described suspicious actions, it also connects to a Falco instance via gRPC and verifies that Falco correctly detected them as suspicious.Notice: this requires Falco to be configured to output its alerts using the gRPC output and append to them the suspicious process environment variables:
sudo falco -c /etc/falco/falco.yaml -c /etc/falco/falco_rules.yaml -o grpc.enabled=true -o grpc_output.enabled=true -o 'append_output[]={"extra_fields": ["proc.env"]}'
Both
run
andtest
commands support loading test descriptions from multiple files and/or folders: this is achieved by using one or multiple times the flags--description-file
and--description-dir
. These flags accept also a comma-separated list of items. Loading a directory means loading all YAML files inside (notice: this is not done recursively). Lastly, they also support loading test descriptions from standard input; this is achieved by not providing any of the aforementioned flags.The
explain
command can be used to explore the YAML properties used to describe the actions to be performed and the expected outcome from executing those actions (this latter has a meaning only for thetest
command). At a high level, each YAML file is a list of test descriptions. The following is an example of it:This example contains 1 test description template: it is possible to recognize that it is a template because it specifies the
cases
keyword. This template will generate 3 tests in total: 2 for the first case and 1 for the last case. Practically speaking, the generated test will be generated by substituting to the%{item.<valueKey>}
placeholders, following combinations of values:For more details regarding test cases, see:
For each of the produced test descriptions, the
event-generator
creates a fake process chain built using the user specified characteristics. In this case:proc0
will run as if it were spawned using the command linearg0 arg1 arg2
byuser1
(which is created on the fly or reused if it already exists on the systemuser2
root
with the specified capabilities in its setsThe third process will perform the actual suspicious actions:
resources
andsteps
lists are used to describe them.resources
are created in order beforesteps
are run. In this case, thecs1
resource is of typeclientServer
: this means that a client and a server will be spawned using the specified l4 protocol and the specified address. In the case of stream-oriented protocols, the client and server will be automatically connected. Other resource types are provided for user convenience, such asfd
(creating a file descriptor of the specified type) orprocess
(spawning a process with the provided characteristics). See the following for aprocess
resource use case leveraging thekill
system call test step:After the
resources
creation, the specifiedsteps
are executed. In this case, there is only 1 step, nameddup1
, of typesyscall
. This will perform adup2
system call using thecs1
resource's client file descriptor as a parameter for theoldFd
system call argument. The syntax used is called "field binding" and allows the exposed value of a previously executed step/resource to be used as the value for the current step field. The syntax format is${<resourceName|stepName>.<pathToExposedField>}
. Currently, thesyscall
step type is the only one that has been introduced. It supports about 20 system calls.If the
test
command is used, after the test execution, theevent-generator
listens for alerts coming from the connected Falco instance, and matches them against the providedexpectedOutcome
. In this case, an alert is expected to be generated for the ruleReverse shell rule
by the sourcesyscall
. The event-generator generates the results of these matchings to inform the user if the actions performed generated the expected results or not.When running multiple tests, becomes relevant the grouping the
event-generator
performs of them. Tests are grouped in test suites based on therule
they are attempting to test. This means that a single test suite is associated with a single rule. Tests results are also grouped by test suite.Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
declarative
command tosuite
because it clearly conveys that the command deals with a group of these and conceptually reflects that the YAML structure defines multiple tests. This also functions as a command namespace, allowing the co-existence of the old approach with the new functionality during the transition period (still TBD). The following steps would be to (a) rename the command fromdeclarative
tosuite
and add deprecation notices for old commands. These changes will be implemented in follow-up PRs.