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

Add file name field for better web experience #693

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

N1neSun
Copy link
Contributor

@N1neSun N1neSun commented Jan 4, 2022

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

@doomedraven
Copy link
Collaborator

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?

@N1neSun
Copy link
Contributor Author

N1neSun commented Jan 4, 2022

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

@doomedraven
Copy link
Collaborator

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?

@N1neSun
Copy link
Contributor Author

N1neSun commented Jan 5, 2022

oh i see, i will check it.

@doomedraven
Copy link
Collaborator

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

@N1neSun
Copy link
Contributor Author

N1neSun commented Jan 5, 2022

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

@doomedraven
Copy link
Collaborator

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?

@N1neSun
Copy link
Contributor Author

N1neSun commented Jan 5, 2022

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.

@kevoreilly
Copy link
Owner

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

@N1neSun
Copy link
Contributor Author

N1neSun commented Jan 6, 2022

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
Copy link
Contributor Author

N1neSun commented Jan 10, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants