Skip to content

Commit

Permalink
Merge pull request #2 from Base4Security/FixingActivityLogs
Browse files Browse the repository at this point in the history
Development-v.1.2
  • Loading branch information
lanfranB4 authored Jul 17, 2024
2 parents 19c3fb5 + 23a307e commit 992e838
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 28 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@

operationsdb.json
docker_client_config
_build/
_build/

dist/*
*egg-*
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def load_requirements(filename='requirements.txt'):
package_dir={"": "src"},
packages=find_packages(where="src"),
install_requires=load_requirements(),
use_scm_version=True,
setup_requires=['setuptools_scm'],
entry_points={
'console_scripts': [
'DOLOST = DOLOST.cli:main'
Expand Down
57 changes: 32 additions & 25 deletions src/DOLOST/services/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,22 @@ def review_observable_ips():
# Start streaming the output of the command
for line in docker_manager.client.api.exec_start(exec_id['Id'], stream=True):
decoded_line = line.decode('utf-8')
if "No such file or directory" in decoded_line :
new_ip = '{"id": 1, "decoy": "---", "ip": "No IPs","timestamp": "----" }'
observable_ips.append(new_ip)
else:
records = decoded_line.strip().split('\r\n')
# Process each record
i = 1
for record in records:
# Split each record by space to separate the timestamp and the IP address
timestamp, decoy, ip_address = record.split(',')
if (ip_address not in excluded_observable_ips):
observable_ips.append('{"id": '+ str(i) +', "decoy": "'+ decoy +'", "ip": "'+ ip_address +'", "timestamp": "' + timestamp + '"}')
i = i + 1
try:
if "No such file or directory" in decoded_line :
new_ip = '{"id": 1, "decoy": "---", "ip": "No IPs","timestamp": "----" }'
observable_ips.append(new_ip)
else:
records = decoded_line.strip().split('\r\n')
# Process each record
i = 1
for record in records:
# Split each record by space to separate the timestamp and the IP address
timestamp, decoy, ip_address = record.split(',')
if (ip_address not in excluded_observable_ips):
observable_ips.append('{"id": '+ str(i) +', "decoy": "'+ decoy +'", "ip": "'+ ip_address +'", "timestamp": "' + timestamp + '"}')
i = i + 1
except Exception:
pass
else:
new_ip = '{"id": 1, "decoy": "---", "ip": "Missing Collector","timestamp": "----" }'
observable_ips.append(new_ip)
Expand Down Expand Up @@ -119,18 +122,22 @@ def review_observable_usage():
# Start streaming the output of the command
for line in docker_manager.client.api.exec_start(exec_id['Id'], stream=True):
decoded_line = line.decode('utf-8')
if "No such file or directory" in decoded_line :
new_data = '{"id": 1, "decoy": "No Usage data","usage": "----" }'
observable_usage.append(new_data)
else:
records = decoded_line.strip().split('\r\n')
# Process each record
i = 1
for record in records:
# Split each record by space to separate the timestamp and the IP address
usage, decoy = record.split(',')
observable_usage.append('{"id": '+ str(i) +', "decoy": "'+ decoy +'", "usage": "' + usage + '"}')
i = i + 1
try:
if "No such file or directory" in decoded_line :
new_data = '{"id": 1, "decoy": "No Usage data","usage": "----" }'
observable_usage.append(new_data)
else:
records = decoded_line.strip().split('\r\n')
# Process each record
i = 1
for record in records:
# Split each record by space to separate the timestamp and the IP address
usage, decoy = record.split(',')
observable_usage.append('{"id": '+ str(i) +', "decoy": "'+ decoy +'", "usage": "' + usage + '"}')
i = i + 1
except Exception:
pass

else:
new_ip = '{"id": 1, "decoy": "Missing Collector","usage": "----" }'
observable_usage.append(new_ip)
Expand Down
4 changes: 2 additions & 2 deletions src/DOLOST/static/js/view_activities_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ function updateUI(logs) {
const logListModal = document.getElementById('logListModal');

// Iterate over logs and append only new ones
logList.innerHTML = '';
logListModal.innerHTML = '';
logs.forEach(log => {
logList.innerHTML = '';
logListModal.innerHTML = '';
const listItem = document.createElement('p');
listItem.textContent = log;
listItem.classList.add('log-line');
Expand Down

0 comments on commit 992e838

Please sign in to comment.