-
-
Notifications
You must be signed in to change notification settings - Fork 505
Nuclei analyzer #2697
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
Nuclei analyzer #2697
Conversation
what is the status of this PR? |
@mlodic, Sir the analyzer is working. I just have to add _monkeypatch(), and then It should be complete. |
thanks for the update please add a reviewer once you finish! |
8e3021e
to
1b474e2
Compare
@drosetti Please review. |
I'm reviewing it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good work but this task is a little more complicated. Important changes must be made.
Plus, when a new docker analyzer is added, also this section must be updated:
api_app/analyzers_manager/migrations/0148_analyzer_config_nuclei.py
Outdated
Show resolved
Hide resolved
"base_path": "api_app.analyzers_manager.observable_analyzers", | ||
}, | ||
"name": "Nuclei", | ||
"description": "A fast and customisable vulnerability scanner powered by simple YAML-based templates", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add markdown link to the Nuclei webpage or docs. That would be rendered by the frontend
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not solved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
api_app/analyzers_manager/migrations/0148_analyzer_config_nuclei.py
Outdated
Show resolved
Hide resolved
build: | ||
context: ../integrations/nuclei_analyzer | ||
dockerfile: Dockerfile | ||
image: pranjalg1310/nuclei-analyzer:1.2.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switch to test instance here, see other docker analyzers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this has not been solved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
mv nuclei /usr/local/bin/ && \ | ||
chmod +x /usr/local/bin/nuclei && \ | ||
rm nuclei_3.3.7_linux_amd64.zip && \ | ||
nuclei -update-template-dir /opt/nuclei-api/nuclei-templates -update-templates && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you do this to update the template project, right? That's a good thing to do.
However, I did not see any implementation of a way to periodically update them. I expect an implementation of a simple cronjob that daily would check and get updates of these templates. In the pcap_analyzer
integration we already added a cronjob, you can take example from there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mlodic I checked the implementation of cron job in pcap_analyzer but could not understand how we are calling these two files - crontab and update_signature. I also tried running pcap analyzer with updated timing to update every minute but could not see any logs being created inside the container.
Could you please guide me more on how to setup cronjob for docker based analyzer and how are they being called?
wget \ | ||
unzip && \ | ||
wget --progress=dot:giga https://github.com/projectdiscovery/nuclei/releases/download/v3.3.7/nuclei_3.3.7_linux_amd64.zip && \ | ||
unzip nuclei_3.3.7_linux_amd64.zip && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this approach has 2 problems:
- first, a custom docker image is really needed? they provide one https://docs.projectdiscovery.io/tools/nuclei/install.
- if it is really needed, cannot this be the base of this custom docker image instead of python? That would help maintain a cleaner image plus we would be able to track Nuclei version updates with the dependabot. If you download the binary like this, we wouldn't be able to be notified by the dependabot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dependabot still missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the Dependabot config. Although I did not know how I could test it, so please take a look.
Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com>
Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com>
Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com>
Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com>
Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com>
Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com>
Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com>
Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com>
Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com>
Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com>
Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com>
Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com>
Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com>
Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com>
a8eac2b
to
eed403c
Compare
Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com>
Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com>
Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com>
I have successfully implemented the flask-shell2http library in my Flask API and used the Nuclei Docker image as the base for my Dockerfile. This has significantly simplified the code. Currently, I haven't updated the Dockerfile version in compose-test.yaml to a test version yet. Could you review it before I proceed? |
build: | ||
context: ../integrations/nuclei_analyzer | ||
dockerfile: Dockerfile | ||
image: pranjalg1310/nuclei-analyzer:1.2.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this has not been solved
"base_path": "api_app.analyzers_manager.observable_analyzers", | ||
}, | ||
"name": "Nuclei", | ||
"description": "A fast and customisable vulnerability scanner powered by simple YAML-based templates", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not solved
|
||
services: | ||
nuclei_analyzer: | ||
image: pranjalg1310/nuclei-analyzer:1.2.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not solved
while [ ! -d "$TEMPLATES_DIR" ] || [ -z "$(ls -A $TEMPLATES_DIR)" ]; do | ||
echo "Templates not found or empty, retrying update in 10 seconds..." | ||
nuclei -update-template-dir $TEMPLATES_DIR -update-templates | ||
sleep 10 | ||
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whis is a potential infinite loop, do not use while
like this. In case the templates are not found, the entrypoint should exit with a custom error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated the code to exit if templates are not downloaded successfully.
done | ||
|
||
echo "Templates downloaded successfully. Starting Flask API..." | ||
exec gunicorn -b 0.0.0.0:4008 --timeout 120 --access-logfile - "app:app" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use all the options we used in the other entrypoint.sh you can found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Included gunicorn logging same as Suricata.
wget \ | ||
unzip && \ | ||
wget --progress=dot:giga https://github.com/projectdiscovery/nuclei/releases/download/v3.3.7/nuclei_3.3.7_linux_amd64.zip && \ | ||
unzip nuclei_3.3.7_linux_amd64.zip && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dependabot still missing
You can already do this during development because you would use the local built from the compose-tests-yml that would overwrite the build from compose.yml |
Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com>
Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com>
Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this task has been challenging. Last steps and we are ready to merge
if template_dir in VALID_TEMPLATE_CATEGORIES: | ||
args.extend(["-t", template_dir]) | ||
else: | ||
print(f"Skipping invalid template directory: {template_dir}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be a warning log and you should add it in the report like this self.report.errors.append(warning)
. Remember to reference the analyzed observable in the log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
RUN adduser -D -h /home/${USER} ${USER} | ||
|
||
# Install required packages using apk and clean cache in the same layer | ||
RUN apk add --no-cache python3 py3-pip \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please select a specific python version here. The more recent the better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
integrations/nuclei_analyzer/app.py
Outdated
try: | ||
json_objects.append(json.loads(line)) | ||
except json.JSONDecodeError: | ||
print(f"Skipping non-JSON line: {line}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
|
||
services: | ||
nuclei_analyzer: | ||
image: pranjalg1310/nuclei-analyzer:{REACT_APP_INTELOWL_VERSION} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the image from intelowlproject repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
build: | ||
context: ../integrations/nuclei_analyzer | ||
dockerfile: Dockerfile | ||
image: pranjalg1310/nuclei-analyzer:test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
intelowlproject repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
# Expose the API port | ||
EXPOSE 4008 | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please add an HEALTHCHECK here as an additional check?
You can check the Dockerfile_nginx
as an example. You can check whether the gunicorn app is up or not after a predefined period that should be the expected time of execution of the entrypoint.sh
script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the health check, I have added an extra endpoint to the API which is being called from the dockerfile.
Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com>
great! |
* Install Kanvas workflow * initial commit Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> * Dockerfile Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> * synchronous nuclei api Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> * removing unnecessary file Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> * dockerfile Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> * made api async Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> * error resolved Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> * async working Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> * another Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> * deepsource errors Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> * gunicorn version fixed Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> * shell2http architecture Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> * deep sorce errors resolved Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> * nuclei file update Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> * new version for dockerfile Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> * migration file changes Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> * error corected Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> * error resolved Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> * dockerfile cleanup code Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> * dependabot added + dockerfile test version Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> * dependabot for python dependencies Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> * healthcheck for api Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> --------- Signed-off-by: pranjalg1331 <pranjaloff13@gmail.com> Co-authored-by: meshery-dev[bot] <132387951+meshery-dev[bot]@users.noreply.github.com>
Description
Closes #1883
Sample Resonse-
Type of change
Please delete options that are not relevant.
Checklist
develop
dumpplugin
command and added it in the project as a data migration. ("How to share a plugin with the community")test_files.zip
and you added the default tests for that mimetype in test_classes.py.FREE_TO_USE_ANALYZERS
playbook by following this guide.url
that contains this information. This is required for Health Checks._monkeypatch()
was used in its class to apply the necessary decorators.MockUpResponse
of the_monkeypatch()
method. This serves us to provide a valid sample for testing.Black
,Flake
,Isort
) gave 0 errors. If you have correctly installed pre-commit, it does these checks and adjustments on your behalf.tests
folder). All the tests (new and old ones) gave 0 errors.DeepSource
,Django Doctors
or other third-party linters have triggered any alerts during the CI checks, I have solved those alerts.Important Rules