You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`setOutputFormat(OutputFileFormat format)`| Set the output format of the analysis (e.g., `HTML`, `JSON`, or `LOG`). |`LOG`|
242
-
|`setAllowedExtensions(String... values)`| Specify file extensions to include in the analysis. By default, allows `.java`, `.kt`, `.gradle`, `.kts`, and `.xml`. |`[".java", ".kt", ".gradle", ".kts", ".xml"]`|
243
-
|`setAutoLaunchBrowser(boolean value)`| Automatically open the generated HTML report in the browser. Set to `false` to disable. |`false`|
244
-
|`setShowSaveDialog(boolean value)`| Display a save dialog for HTML and JSON reports. Set to `false` to disable. |`false`|
245
-
|`setLogListener(LogListener listener)`| Set a custom listener for capturing logs during analysis (useful for Android integration). |`null`|
246
-
240
+
| Configuration Option | Description | Default Value |
|`setOutputFormat(OutputFileFormat format)`| Set the output format of the analysis (e.g., `HTML`, `JSON`, or `LOG`). |`LOG`|
243
+
|`setAllowedExtensions(String... values)`| Specify file extensions to include in the analysis. By default, allows `.java`, `.kt`, `.gradle`, `.kts`, and `.xml`. |`[".java", ".kt", ".gradle", ".kts", ".xml"]`|
244
+
|`setAutoLaunchBrowser(boolean value)`| Automatically open the generated HTML report in the browser. Set to `false` to disable. |`false`|
245
+
|`setShowSaveDialog(boolean value)`| Display a save dialog for HTML and JSON reports. Set to `false` to disable. |`false`|
246
+
|`setLogListener(LogListener listener)`| Set a custom listener for capturing logs during analysis (useful for Android integration). |`null`|
247
+
|`addCustomDetector(BaseDetector detector)`| Add your own custom detector to identify specific patterns or vulnerabilities in the code. |`null`|
247
248
248
249
> **Important Notes**
249
250
> If you choose the JSON or HTML output format, you **must** use either `setAutoLaunchBrowser` or
250
251
> `setShowSaveDialog`. These methods ensure that the output is handled properly.
251
252
252
253
### <ahref="https://github.com/delvelin/example-kotlin">See Example Project >></a>
253
254
255
+
Sure! Here is the additional README documentation for using `Delvelin` with a custom detector `ExampleCustomDetector`:
256
+
257
+
### Usage with Custom Detector
258
+
259
+
Below is an example of how to use Delvelin with a custom detector `ExampleCustomDetector`.
260
+
261
+
#### Step-by-step
262
+
263
+
1. Create a custom detector class like `ExampleCustomDetector`.
264
+
2. Add detection implementation in the `detect(line: String, lineNumber: Int)` and `detect(content: String)` methods.
265
+
3. Create a test function that sets the output format, adds the custom detector, and runs the scan.
266
+
267
+
#### Example Custom Detector
268
+
269
+
The following custom detector detects a specific pattern in the code. It checks each line of code and the entire content to find the pattern called `examplePattern`.
val specificLocation = specificLocation(lineNumber)
282
+
setValidVulnerability(
283
+
specificLocation,
284
+
"Example finding",
285
+
"Detected example pattern in the code"
286
+
)
287
+
}
288
+
}
289
+
290
+
overridefundetect(content:String) {
291
+
// Implementation of full content-based detection
292
+
if (content.contains("examplePattern")) {
293
+
val specificLocation = specificLocation(-1) // -1 to denote whole content
294
+
setValidVulnerability(
295
+
specificLocation,
296
+
"Example finding",
297
+
"Detected example pattern in the full content"
298
+
)
299
+
}
300
+
}
301
+
}
302
+
```
303
+
304
+
#### Using Custom Detector in Tests
305
+
306
+
Here is an example test that uses `ExampleCustomDetector` with Delvelin. This test sets the output format to HTML and adds the custom detector before running the scan.
307
+
308
+
```kotlin
309
+
@Test
310
+
fun`test using your own custom detector`() {
311
+
Delvelin().setOutputFormat(OutputFileFormat.HTML)
312
+
.addCustomDetector(ExampleCustomDetector())
313
+
.scan()
314
+
}
315
+
```
316
+
254
317
# 4. License
255
318
This project is licensed under [MIT License](LICENSE).
0 commit comments