Skip to content

fix: follow symlinks when iterating entries directory#1642

Merged
reddevillg merged 1 commit into
OpenAtom-Linyaps:masterfrom
dengbo11:fix-cli-content
Apr 21, 2026
Merged

fix: follow symlinks when iterating entries directory#1642
reddevillg merged 1 commit into
OpenAtom-Linyaps:masterfrom
dengbo11:fix-cli-content

Conversation

@dengbo11

Copy link
Copy Markdown
Collaborator
  1. Add QDirIterator::FollowSymlinks flag to directory iterator in Cli::content method
  2. This enables proper resolution of desktop files from symlinked entries/share directories
  3. Previously, symlinks in the entries directory were not being followed, causing desktop files pointed to by symbolic links to be missed
  4. Add two test cases to verify symlink resolution works correctly:
    • contentResolvesDesktopFromSymlinkedEntriesShareDir: tests resolving desktop from symlinked entries
    • contentResolvesOverlayDesktopFromSymlinkedEntriesShareDir: tests overlay desktop resolution with symlinks

Influence:

  1. Test content command with applications that have symlinked entries/ share directories
  2. Verify desktop file discovery works correctly when entries/share is a symlink to files/share
  3. Test both default directory fallback and overlay directory scenarios with symlinked paths
  4. Verify no regression in normal (non-symlinked) directory traversal
  5. Test that symlinked directories pointing outside expected paths are handled safely

@dengbo11 dengbo11 requested a review from reddevillg April 21, 2026 09:23

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Cli::content method to follow symlinks during directory iteration and introduces new test cases to verify symlink resolution for desktop files. A security concern was identified regarding the use of QDirIterator::FollowSymlinks, which could expose the system to path traversal attacks if symlinks point outside the package's layer directory. It is recommended to validate that all resolved paths remain within the intended directory scope.

QDirIterator it(entriesDir.absolutePath(),
QDir::AllEntries | QDir::NoDot | QDir::NoDotDot | QDir::System,
QDirIterator::Subdirectories);
QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

Enabling QDirIterator::FollowSymlinks allows the iterator to descend into symlinked directories. This introduces a potential security risk if a package contains malicious symlinks pointing to sensitive host files (e.g., /etc/shadow).

When FollowSymlinks is active, it.fileInfo().absoluteFilePath() returns the path of the symlink target. If that target is outside the entriesDir, entriesDir.relativeFilePath(entryPath) will produce a path starting with ... It is highly recommended to validate that the resolved entryPath is still within the package's layer directory to prevent path traversal vulnerabilities during the export process.

@dengbo11 dengbo11 marked this pull request as draft April 21, 2026 09:38
@dengbo11 dengbo11 marked this pull request as draft April 21, 2026 09:38
@dengbo11 dengbo11 removed the request for review from reddevillg April 21, 2026 09:40
1. Add QDirIterator::FollowSymlinks flag to directory iterator in
Cli::content method
2. This enables proper resolution of desktop files from symlinked
entries/share directories
3. Previously, symlinks in the entries directory were not being
followed, causing desktop files pointed to by symbolic links to be
missed
4. Add two test cases to verify symlink resolution works correctly:
   - contentResolvesDesktopFromSymlinkedEntriesShareDir: tests resolving
desktop from symlinked entries
   - contentResolvesOverlayDesktopFromSymlinkedEntriesShareDir: tests
overlay desktop resolution with symlinks

Influence:
1. Test content command with applications that have symlinked entries/
share directories
2. Verify desktop file discovery works correctly when entries/share is a
symlink to files/share
3. Test both default directory fallback and overlay directory scenarios
with symlinked paths
4. Verify no regression in normal (non-symlinked) directory traversal
5. Test that symlinked directories pointing outside expected paths are
handled safely
@codecov

codecov Bot commented Apr 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
libs/linglong/src/linglong/cli/cli.cpp 0.00% 0 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
libs/linglong/src/linglong/cli/cli.cpp 1.77% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dengbo11 dengbo11 marked this pull request as ready for review April 21, 2026 12:22
@dengbo11 dengbo11 requested a review from reddevillg April 21, 2026 12:56
@deepin-ci-robot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dengbo11, reddevillg

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@reddevillg reddevillg merged commit 8e77467 into OpenAtom-Linyaps:master Apr 21, 2026
14 of 16 checks passed
@dengbo11 dengbo11 deleted the fix-cli-content branch July 1, 2026 05:47
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