CAPEv2 icon indicating copy to clipboard operation
CAPEv2 copied to clipboard

Add file name field for better web experience

Open N1neSun opened this issue 3 years ago • 11 comments

I don't know if this is a good pr.

  • Add a field to the database to display the real file name.
  • need cd /opt/CAPEv2/utils/db_migration && alembic upgrade head and restart cape systemctl restart cape

N1neSun avatar Jan 04 '22 10:01 N1neSun

there is no such thing as good/bad PR, all of them are amazing, as all of us having different use cases

could you give me a bit more details please, so that would just show the original filename on web?

doomedraven avatar Jan 04 '22 11:01 doomedraven

Yes, this can show the original filename on web using the database filename field.

N1neSun avatar Jan 04 '22 11:01 N1neSun

i might be wrong so correct me if needed, what i see is basically that if we rename path_to_extract filename to child.filename we will get the same no?

doomedraven avatar Jan 05 '22 08:01 doomedraven

oh i see, i will check it.

N1neSun avatar Jan 05 '22 08:01 N1neSun

yes i think if we rename the file just after extract, instead of using path_to_extract, theorically that should do the trick to get the original filename

doomedraven avatar Jan 05 '22 09:01 doomedraven

yes,however, if there are characters such as unicode in the file name, there may be problems in subsequent analysis.

N1neSun avatar Jan 05 '22 09:01 N1neSun

hm, wouldn't that give problems when we store that in db? we can use sanitize_filename to ensure that it not gives problems later when renaming, but it can remove some chars, that probably will show a bit different name then?

doomedraven avatar Jan 05 '22 09:01 doomedraven

yes, there is no problems store in db.the purpose of this pr is to save the original file name in the database and display it on the web without being affected by sanitize_filename.

N1neSun avatar Jan 05 '22 09:01 N1neSun

But if the original filename contains certain characters and is un-sanitized, will this not cause the entire web page to fail?

kevoreilly avatar Jan 06 '22 11:01 kevoreilly

But if the original filename contains certain characters and is un-sanitized, will this not cause the entire web page to fail?

In fact, it should not be possible, because the django framework and python itself will help us clean up some abnormal strings, but I am not sure whether it can be bypassed.

N1neSun avatar Jan 06 '22 11:01 N1neSun

Considering that there may be some concerns about this function (actually static and pcap, etc. are all displayed origin filenames), I added enable in web.conf.

N1neSun avatar Jan 10 '22 10:01 N1neSun