Code Monkey home page Code Monkey logo

Comments (2)

kn0wl3dge avatar kn0wl3dge commented on June 14, 2024 1

When a worker submit its results through the Django API:

@action(detail=True, methods=["POST"])
def submit_results(self, request, pk=None):
"""Extra API endpoint used by the Windows Agent to submit results
of its job. The results are send through a file (currently being
a JSON or a ZIP)/
Args:
request (Request): Request made by the Agent.
pk (UUID, optional): Worker UUID. Defaults to None.
Returns:
Response: Send back if results storing was a success or if any
error has been encoutered.
"""
worker = get_object_or_404(Worker, pk=pk)
if worker.job and worker.job.state != JobState.DONE:
if "results" in request.data.keys():
worker.job.end(request.data["results"])
worker.job.save()
process_results.delay(worker.job.id)
return Response({"success": "Results successfully stored"})
else:
return Response({"error": "Can't find 'results' param"})
return Response({"error": "Worker is in an incorrect state"})

the file is saved via the job instance with the following computed path:
RESULTS_DIR = "results" # /data/results
def get_upload_filename(instance, filename):
"""Compute path where the job result will be stored.
Args:
instance (Job): Job instance associated to the results.
filename (String): Name of the uploaded file.
Returns:
String: Computed path where the results will be stored.
"""
dirs = wrap(instance.malware.sha256, 2)
ext = filename.split(".")[-1]
return f"{RESULTS_DIR}/{'/'.join(dirs[:5])}/{instance.malware.sha256}_{instance.job_type}.{ext}"

So, if I launch two jobs of the same type and on the same malware, the files paths will be identical. As a consequences, the result file will be overwritten and both jobs will be associated to the same result file.

from sledre.

0pendev avatar 0pendev commented on June 14, 2024

Could you elaborate ? Maybe add some way of producing the bug etc.

from sledre.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.