Skip to content
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

Added Delete for Completed Scan records #102

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
UPLOAD_DIRECTORY="../common/Uploads"
MONGODB_HOST="mongo-service"
MONGODB_HOST="127.0.0.1"
MONGODB_PORT=27017
UTILITIES_PATH="../Utilities"
REDIS_URL="redis://redis-service:6379"
Expand Down
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Prerequisites

Please answer the following questions for yourself before submitting an issue. **YOU MAY DELETE THE PREREQUISITES SECTION.**

- [ ] I am running the latest version
- [ ] I checked the documentation and found no answer
- [ ] I checked to make sure that this issue has not already been filed
- [ ] I'm reporting the issue to the correct repository (for multi-repository projects)

# Expected Behavior
The delete button has been added to the "Completed Scans" section of the Scan8 tool, and is easily accessible to users. It is labeled with a delete tag match the existing Scan8 user interface. The delete button works as expected, and removes the completed scan files without causing any unintended consequences.


# Current Behavior

Currently, there is no way to delete completed scan files in Scan8, which is problematic for users who want to remove unnecessary scan files from their system.

39 changes: 39 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Description

Currently, there is no way to delete completed scan files in Scan8, which is problematic for users who want to remove unnecessary scan files from their system. However, I have implemented a delete button that can be used to delete completed scans. When pressed, the button will remove the completed scan files immediately.



Fixes # (issue)

The delete button has been added to the "Completed Scans" section of the Scan8 tool, and is easily accessible to users. It is labeled with a trash can icon and has been styled to match the existing Scan8 user interface. The delete button works as expected, and removes the completed scan files without causing any unintended consequences.

## Type of change

Please delete options that are not relevant.


- [ ] New feature (non-breaking change which adds functionality)


# Testing

The application comes with a test suite to help users ensure correct installation and help developers verify any updates.

The following tests should return **ok** status upon running the unit-test command `python3 app.py -v` from the `/Testing` directory.

- [ ] `testResultsJSON`
- [ ] `testResults`
- [ ] `testUploads`
- [ ] `testResultsDirectoryPresent`
- [ ] `testUploadsDirectoryPresent`
# Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
3 changes: 2 additions & 1 deletion Coordinator/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
### Master Node
### Coordinator Node

The Coordinator Node listens to updates for new scans, subsequently creating and adding scan jobs to the Redis Queue.
1 change: 1 addition & 0 deletions Dashboard/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
### Dashboard

The Dashboard provides a responsive web interface for uploading files for new scans and tracking the status of all the submitted scans.
18 changes: 16 additions & 2 deletions Dashboard/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from werkzeug.utils import secure_filename
import os
import uuid
from pymongo import MongoClient
from pymongo import MongoClient, errors
import json
from hurry.filesize import size, si
from dotenv import load_dotenv
Expand Down Expand Up @@ -31,7 +31,7 @@ def index():
queued = queuedScans.find()
running = runningScans.find()
completed = completedScans.find()
return render_template('index.html', prequeued=prequeued, queued=queued, running=running, completed=completed, newScanUrl=url_for('newScan'))
return render_template('index.html', prequeued=prequeued, queued=queued, running=running, completed=completed, newScanUrl=url_for('newScan'),delete_completed=url_for('deleteCompleted', file='<file>'))


def new_scan():
Expand Down Expand Up @@ -79,12 +79,26 @@ def generate():
return Response(generate(), mimetype='text/event-stream')


def delete_completed(file):
try:
file = completedScans.find_one({'_id': file})
if file:
file_id = file['_id']
completedScans.delete_one({'_id': file_id})
return redirect(url_for('dashboard'))
except errors.OperationFailure as e:
return {"message": f"Error: {e}"}, 400


app.add_url_rule("/", endpoint="dashboard", view_func=index, methods=['GET'])
app.add_url_rule("/newScan", endpoint="newScan",
view_func=new_scan, methods=['GET'])
app.add_url_rule("/progress", endpoint="progress",
view_func=progress, methods=['GET'])
app.add_url_rule("/upload", endpoint="upload",
view_func=upload_files, methods=['GET', 'POST'])
app.add_url_rule("/deleteCompleted/<file>", endpoint="deleteCompleted",
view_func=delete_completed, methods=['GET', 'POST'])

if __name__ == "__main__":
app.run(host="0.0.0.0",debug=True)
3 changes: 3 additions & 0 deletions Dashboard/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ <h6>Number of files: {{ item['files']['total'] }}</h6>
<div id={{ item["_id"] }} class="progress-bar" style="width: 100%;"></div>
</div>
</div>
<form method="POST" action="{{ url_for('deleteCompleted', file=item['_id']) }}">
<button type="submit" class="btn btn-danger btn-sm">Delete</button>
</form>
</div>
{% endfor %}
</div>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Scan8
Scan8 (Open for GSoC and Hacktoberfest)
========

Scan8 is a distributed scanning system for detecting trojans, viruses, malware, and other malicious threats embedded in files. The system will allow one to submit a list of URLs or files and get the scan results in return.
Expand Down
1 change: 1 addition & 0 deletions Worker/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
### Worker Node

The Worker Node listens to updates for new jobs in Redis Queue and executes them.