-
Notifications
You must be signed in to change notification settings - Fork 890
fix: Convert full source paths to relative in logs #8823
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Tamás Bari <[email protected]>
Signed-off-by: Tamás Bari <[email protected]>
CMakeLists.txt
Outdated
|
|
||
| get_git_head_revision(GIT_REFSPEC GIT_SHA1) | ||
|
|
||
| add_definitions(-DSOURCE_ROOT="${CMAKE_SOURCE_DIR}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please no
this should be properly defined in config.h.in
if you work on the code, and have this global define you cannot figure out where it is coming from
in addition, we should always use the cmake so-called target APIs
https://cmake.org/cmake/help/latest/command/target_compile_definitions.html for example
src/libsync/logger.cpp
Outdated
| QString msg = qFormatLogMessage(type, ctx, message); | ||
|
|
||
| // We want to change the full path of the source file to relative, | ||
| // to reduce log size and also, to not leak paths into logs. | ||
| // To help with this, there is a placeholder in the message pattern | ||
| // for the file path ("<file-path-here>"). | ||
| QString filePath; | ||
| if (ctx.file != nullptr) { | ||
| static const QString projectRoot = QStringLiteral(SOURCE_ROOT); | ||
|
|
||
| filePath = QFileInfo(QString::fromLocal8Bit(ctx.file)).absoluteFilePath(); | ||
| if (filePath.startsWith(projectRoot)) { | ||
| filePath = filePath.mid(projectRoot.size() + 1); | ||
| } | ||
| } | ||
|
|
||
| static const QString filePathPlaceholder = "<file-path-here>"; | ||
| msg.replace(filePathPlaceholder, filePath); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am really concerned about the performance implication of that change
we already are a bit slow when printing logs
maybe you could use a hash map to have a quick mapping from absolute paths to relative ones and just add this info somewhere in the log line
Instead of trying to convert them to relative paths. Signed-off-by: Tamás Bari <[email protected]>
Signed-off-by: Tamás Bari <[email protected]>
|
| #include <QStringList> | ||
| #include <QtGlobal> | ||
| #include <QTextCodec> | ||
| #include <QtGlobal> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this change really needed ?
src/libsync/logger.cpp
Outdated
| namespace OCC | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please revert
current style is
namespace OCC {
src/libsync/logger.cpp
Outdated
| { | ||
| if (_logstream) | ||
| { | ||
| if (_logstream) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please split code style fixes into a separate commit
makes it easier to selectively revert or test changes while keeping code style improvements
src/libsync/logger.cpp
Outdated
| QFile file(dir); | ||
| file.setPermissions(perm); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
src/libsync/logger.cpp
Outdated
| int maxNumber = -1; | ||
| const auto collidingFileNames = dir.entryList({QStringLiteral("%1.*").arg(newLogName)}, QDir::Files, QDir::Name); | ||
| for(const auto &fileName : collidingFileNames) { | ||
| for (const auto &fileName : collidingFileNames) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
src/libsync/logger.cpp
Outdated
| auto previousLog = QString{}; | ||
| switch (type) | ||
| { | ||
| switch (type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
src/libsync/logger.cpp
Outdated
| { | ||
| qSetMessagePattern(QStringLiteral("%{time yyyy-MM-dd hh:mm:ss:zzz} [ %{type} %{category} %{file}:%{line} " | ||
| "]%{if-debug}\t[ %{function} ]%{endif}:\t%{message}")); | ||
| qSetMessagePattern(QStringLiteral("%{time yyyy-MM-dd hh:mm:ss:zzz} [%{type} %{category}]:\t%{message}; %{function} %{if-debug}%{file}%{endif}:%{line}")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please do not change the order ?
omitting the file may save some characters but we should keep the order unchanged to not break possibly existing parsers for the logs
src/libsync/logger.cpp
Outdated
| { | ||
| static long long int linesCounter = 0; | ||
| const auto &msg = qFormatLogMessage(type, ctx, message); | ||
| QString msg = qFormatLogMessage(type, ctx, message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| QString msg = qFormatLogMessage(type, ctx, message); | |
| const auto msg = qFormatLogMessage(type, ctx, message); |
src/libsync/logger.cpp
Outdated
| if (_doFileFlush || _linesCounter >= MaxLogLinesBeforeFlush || type == QtMsgType::QtWarningMsg || type == QtMsgType::QtCriticalMsg | ||
| || type == QtMsgType::QtFatalMsg) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment (code style)
nilsding
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change won't resolve the leakage of the complete build path though.
The logger macros (and apparently Qt's old SLOT() macro as well?) embed __FILE__ at compile time, so the full path still ends up in the built binaries:
% strings -n 30 ./bin/nextclouddev | egrep '^/.+/desktop/src/gui/' | sort -u | head -n10
/home/jyrki/src/nextcloud/desktop/src/gui/accountmanager.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/accountsettings.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/accountsetupcommandlinemanager.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/accountsetupfromcommandlinejob.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/accountstate.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/addcertificatedialog.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/application.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/application.cpp:633
/home/jyrki/src/nextcloud/desktop/src/gui/callstatechecker.cpp
/home/jyrki/src/nextcloud/desktop/src/gui/caseclashfilenamedialog.cpp|
I feel resistance to to change the logging pattern. Which I can understand, very minor benefit to it. The security part is somewhat important, but this PR wasn't really about that. Plus what @nilsding found suggests that we should go about it very differently. Should we just ditch this PR? |
Signed-off-by: Rello <[email protected]>
will enable to dynamically fetch the list of files inside a folder for now, only basic infrastructure plugging into CfApi is there Signed-off-by: Matthieu Gallien <[email protected]>
will enable to dynamically fetch the list of files inside a folder for now, only basic infrastructure plugging into CfApi is there Signed-off-by: Matthieu Gallien <[email protected]>
will prevent continuous loop of trying to populated the root folder on loop Signed-off-by: Matthieu Gallien <[email protected]>
Signed-off-by: Matthieu Gallien <[email protected]>
will make all folders be initially skipped by cerating an entry into a new type of blacklist upon access by the users they will be removed from this list and synced as normal folders that is a kid of automatic selective sync mechanism (but still creating the folders that are skipped) that would allow the user to know them and access them triggering the dynamic fetching mechanism Signed-off-by: Matthieu Gallien <[email protected]>
Signed-off-by: Matthieu Gallien <[email protected]>
Signed-off-by: Matthieu Gallien <[email protected]>
should make the logic much more reliable Signed-off-by: Matthieu Gallien <[email protected]>
should enable proper type handling for virtual directories (i.e. on-demand populated folders) Signed-off-by: Matthieu Gallien <[email protected]>
after having populated the entries in a on-demand folder, update its type in database to ensure updated state only virtual folders have the on-demand feature enabled and that should happen only once as we always fully populated a folder Signed-off-by: Matthieu Gallien <[email protected]>
do not forget that a virtual folder is being also a folder Signed-off-by: Matthieu Gallien <[email protected]>
when a folder is being hydrated (is no longer virtual), let's change the DB record type to be an usual folder part of the normal synchronization Signed-off-by: Matthieu Gallien <[email protected]>
Signed-off-by: Matthieu Gallien <[email protected]>
Signed-off-by: Matthieu Gallien <[email protected]>
Signed-off-by: Matthieu Gallien <[email protected]>
Bumps [cpp-linter/cpp-linter-action](https://github.com/cpp-linter/cpp-linter-action) from 2.16.4 to 2.16.5. - [Release notes](https://github.com/cpp-linter/cpp-linter-action/releases) - [Commits](cpp-linter/cpp-linter-action@7dacd91...b7fbdde) --- updated-dependencies: - dependency-name: cpp-linter/cpp-linter-action dependency-version: 2.16.5 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: Nextcloud bot <[email protected]>
… Account
With this change some warnings from QObject like these are gone now:
QObject: Cannot create children for a parent that is in a different thread.
I suspect this might have been causing some "random" crashes during
normal usage as well. QNAMs are supposed to be used from the same
thread they were created in, which (as far as I could tell anyway) isn't
the case within async image providers...
This change is similar to how the `ImageResponse` class inside
`src/gui/tray/usermodel.cpp` fetches a remote resource.
Signed-off-by: Jyrki Gadinger <[email protected]>
as documented here https://docs.nextcloud.com/server/latest/developer_manual/client_apis/WebDAV/chunking.html#uploading-chunks Signed-off-by: Matthieu Gallien <[email protected]>
Signed-off-by: Rello <[email protected]>
Signed-off-by: Tamás Bari <[email protected]>
Signed-off-by: Tamás Bari <[email protected]>
…ialogs Changed HTML anchor attribute delimiters from single quotes to double quotes in conflictdialog.cpp and caseclashfilenamedialog.cpp to properly handle file paths containing single quote characters. Fixes issue where clicking links for files with single quotes in their path would fail due to malformed HTML. Signed-off-by: GitHub Copilot <[email protected]> Co-authored-by: Rello <[email protected]>
Use Utility::escape() to HTML-escape file URLs before embedding them in anchor tags. This ensures both single quotes and double quotes (and other HTML special characters) are properly handled. The toHtmlEscaped() function converts: - ' to ' - " to " - & to & - < to < - > to > This fixes the issue where changing from single to double quote delimiters would break with double quotes instead. Signed-off-by: GitHub Copilot <[email protected]> Co-authored-by: nilsding <[email protected]>
Signed-off-by: Nextcloud bot <[email protected]>
In #8860 I noticed that the "insufficient memory error" message is logged if the last error was anything but `ERROR_INSUFFICIENT_BUFFER` - fix comparison operator - format Windows error codes with a hex code and message Signed-off-by: Jyrki Gadinger <[email protected]>
Signed-off-by: Tamás Bari <[email protected]>
Signed-off-by: Nextcloud bot <[email protected]>
Signed-off-by: Nextcloud bot <[email protected]>
Signed-off-by: Nextcloud bot <[email protected]>
Reported at Transifex Signed-off-by: rakekniven <[email protected]>
Signed-off-by: Jyrki Gadinger <[email protected]>
Signed-off-by: Nextcloud bot <[email protected]>
Signed-off-by: Iva Horn <[email protected]>
… dependencies. Signed-off-by: Iva Horn <[email protected]>
Signed-off-by: Nextcloud bot <[email protected]>
Adjust .gitignore to accept a file with 'build' in the name. Signed-off-by: Camila Ayres <[email protected]>
Signed-off-by: Tamás Bari <[email protected]>
This reverts commit 74f0d90efac5c4c3174bec8444efda8ed2295aa0.
This reverts commit c92f947bda408693f239cd2469262477677e0033.
Signed-off-by: Tamás Bari <[email protected]>
So, I reverted my previous changes. Instead I introduced the Which is coming from the RUNPATHs. That will be taken care of by the deploy tools. |
|
Artifact containing the AppImage: nextcloud-appimage-pr-8823.zip Digest: To test this change/fix you can download the above artifact file, unzip it, and run it. Please make sure to quit your existing Nextcloud app and backup your data. |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |




This is a quick fix to convert the full source paths to relative ones in log files. Saves a bit of spaces and prevents a security risk (leaking CI paths into logs).
I understand that the solution is a bit wonky. I've looked at other possibilities and found this the least bad. Suggestions welcome.