1
- # How do I...
1
+ # Build and run Tsunami
2
2
3
- This page answers common how-to questions that may come up when using Tsunami.
4
-
5
- ## Content
6
-
7
- How do I...
8
-
9
- * ... [ build and execute the scanner?] ( #build_n_execute )
10
- * ... [ install Tsunami plugins?] ( #install_plugins )
11
- * ... [ create a new Tsunami plugin?] ( #create_plugins )
12
- * ...
13
- [ apply my plugins to certain types of services / software?] ( #filter_plugins )
14
- * ... [ add command line arguments for my plugin?] ( #command_line )
15
- * ... [ add configuration properties for my plugin?] ( #configuration )
16
-
17
- ## <a name =" build_n_execute " ></a >... build and execute the scanner?
3
+ ## Build and run the scanner
18
4
19
5
To build the scanner, go to the root path of the project and execute the
20
6
following command:
@@ -53,7 +39,7 @@ NOTE: Currently Tsunami only supports loading plugins from its `classpath`. We
53
39
are adding new features to allow users specifying plugin installation folders in
54
40
the config file of Tsunami.
55
41
56
- ## < a name = " install_plugins " ></ a >... install Tsunami plugins?
42
+ ## Install Tsunami plugins
57
43
58
44
As mentioned above, Tsunami plugins must be installed into a folder that can be
59
45
recognized by Tsunami at runtime. This directory can be any arbitrary folder as
@@ -73,133 +59,3 @@ wordpress-installation.jar exposed-jupyter-notebook.jar
73
59
74
60
NOTE: We are adding new features to allow users specifying plugin installation
75
61
folders in the config file of Tsunami.
76
-
77
- ## <a name =" create_plugins " ></a >... create a new Tsunami plugin?
78
-
79
- Follow examples from the
80
- [ tsunami-security-scanner-plugins] ( https://github.com/google/tsunami-security-scanner-plugins )
81
- repo.
82
-
83
- ## <a name =" filter_plugins " ></a >... apply my plugins to certain types of services / software?
84
-
85
- Tsunami supports several filtering annotations that can be applied to a plugin.
86
- When used, plugins will only be selected for execution when the filtering
87
- criteria is satisfied.
88
-
89
- In the following example, a ` ForServiceName ` annotation is applied to the
90
- ` WebFingerprinter ` plugin. ` ForServiceName ` annotation compares the
91
- ` service_name ` field of the ` NetworkService ` protobuf with its target values.
92
- The annotated plugin will only be selected for execution when there is a match.
93
- Here the ` WebFingerprinter ` plugin will run when the scan target exposes either
94
- a ` http ` or a ` https ` service.
95
-
96
- ``` java
97
- // ...
98
- @ForServiceName ([" http" , " https" ])
99
- public final class WebFingerprinter implements ServiceFingerprinter {
100
- // ...
101
- }
102
- ```
103
-
104
- ## <a name =" command_line " ></a >... add command line arguments for my plugin?
105
-
106
- Tsunami uses [ jCommander] ( https://jcommander.org/ ) for command line argument
107
- parsing. In order to add new command line arguments for your plugin, first
108
- define the data class for holding all the arguments. You can follow the
109
- [ jCommander] ( https://jcommander.org/ ) tutorial to learn more about the utility.
110
-
111
- ``` java
112
- @Parameters (separators = " =" )
113
- public class MyPluginArgs implements CliOption {
114
- @Parameter (names = " --param" , description = " Description for param." )
115
- private String param;
116
-
117
- @Override
118
- public void validate () {
119
- // Validate the command line value.
120
- }
121
- }
122
- ```
123
-
124
- Then inject an instance of this data class into your plugin's constructor like
125
- so:
126
-
127
- ``` java
128
- // ...
129
- public final class MyPlugin implements VulnDetector {
130
- private final MyPluginArgs args;
131
- @Inject
132
- MyPlugin (MyPluginArgs args ) {
133
- this . args = checkNotNull(args);
134
- }
135
- // ...
136
- }
137
- ```
138
-
139
- The scanner will automatically parse the command line arguments passed to the
140
- binary, create an instance of the data class from parsed values, and inject the
141
- instance into your plugin.
142
-
143
- ## <a name =" configuration " ></a >... add configuration properties for my plugin?
144
-
145
- Similar to command line argument, you could add configuration properties for
146
- your plugins and tweak configurations using a config file. Currently Tsunami
147
- supports loading configs from a YAML file.
148
-
149
- Tsunami uses
150
- [ snakeyaml] ( https://bitbucket.org/asomov/snakeyaml/wiki/Documentation ) to parse
151
- the YAML config file. In order to add configuration properties to your plugin,
152
- first you need to define a data class for holding all the configuration values.
153
- Currently Tsunami only supports standard Java data types for configuration like
154
- strings, numbers (` int ` , ` long ` , ` float ` , ` double ` , etc), lists and maps of
155
- standard Java data types.
156
-
157
- ``` java
158
- // All config classes must be annotated by this ConfigProperties annotation in
159
- // order for Tsunami to recognize the config class.
160
- @ConfigProperties (prefix = " my.plugin.configs" )
161
- public class MyPluginConfigs {
162
- String stringValue;
163
- long longValue;
164
- List<String > listValues;
165
- Map<String , String > mapValues;
166
- }
167
- ```
168
-
169
- Then similar to the command line arguments, you can inject an instance of this
170
- data class into your plugin's constructor like so:
171
-
172
- ``` java
173
- // ...
174
- public final class MyPlugin implements VulnDetector {
175
- private final MyPluginConfigs configs;
176
- @Inject
177
- MyPlugin (MyPluginConfigs configs ) {
178
- this . configs = checkNotNull(configs);
179
- }
180
- // ...
181
- }
182
- ```
183
-
184
- The scanner will parse the configuration file when it starts, create an instance
185
- of the data class from the config data, and inject the instance into your
186
- plugin.
187
-
188
- Following is an example config file for the previously defined ` MyPluginConfigs `
189
- object.
190
-
191
- ``` yaml
192
- # tsunami.yaml file
193
- my :
194
- plugin :
195
- configs :
196
- stringValue : " example value"
197
- long_value : 123
198
- list_values :
199
- - " a"
200
- - " b"
201
- - " c"
202
- mapValues :
203
- key1 : " value1"
204
- key2 : " value2"
205
- ` ` `
0 commit comments