Skip to content

Conversation

@simondeziel
Copy link
Member

No description provided.

@simondeziel simondeziel requested a review from Copilot August 11, 2025 01:01

This comment was marked as outdated.

@simondeziel simondeziel force-pushed the idmapset-linux branch 4 times, most recently from d910bd1 to 7ac9bb1 Compare August 11, 2025 16:29
@simondeziel simondeziel requested a review from Copilot August 11, 2025 17:29

This comment was marked as outdated.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses various golangci-lint issues throughout the LXD idmap codebase by fixing error messages, adding documentation, improving naming conventions, refactoring code for better maintainability, and adding comprehensive test coverage.

  • Fixes error message capitalization inconsistencies and adds comprehensive test coverage
  • Adds proper documentation to exported functions and improves code organization
  • Refactors duplicate code patterns and improves function naming conventions

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
lxd/idmap/parse_linux_test.go Adds comprehensive test suite for ParseRawIdmap function
lxd/idmap/parse_linux.go Fixes error message capitalization consistency
lxd/idmap/idmapset_linux_test.go Adds extensive test coverage for various idmap functions
lxd/idmap/idmapset_linux.go Major refactoring with documentation, naming improvements, and code consolidation
fuidshift/main_shift.go Updates function calls to match renamed methods
.golangci.yaml Removes exclusion for idmapset_linux.go from linting

@simondeziel simondeziel marked this pull request as ready for review August 11, 2025 19:29
@simondeziel simondeziel requested a review from tomponline August 11, 2025 19:29

scanner := bufio.NewScanner(f)
for scanner.Scan() {
// Skip comments
Copy link
Member

Choose a reason for hiding this comment

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

Did you check history of this change and why it was added?

Copy link
Member Author

Choose a reason for hiding this comment

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

I had not done it because the files in questions are coming from the procfs which contains stuff build dynamically by the kernel. Having a comment show up there would be weird.

That said, I tracked it down to being introduced by commit dc64c84 in 2017 and appears to have been a copy-n-paste from the getFromShadow() function that predates it. The shadow variant deals with files created by humans so comments are possible.

Lastly, I did not include it in the final list of tests but even if comments are somehow present in what the getFromProc reads, it has logic to skip bogus lines. I've now reinstate an unlikely test where a comment is present.

Copy link
Member

Choose a reason for hiding this comment

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

and appears to have been a copy-n-paste from the getFromShadow() function that predates it.

Ah yeah seems likely indeed cheers

tomponline
tomponline previously approved these changes Aug 13, 2025
Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

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

Thanks!

@tomponline
Copy link
Member

@simondeziel are you able to reopen this for the cla check?

@tomponline tomponline merged commit f2b8b9a into canonical:main Aug 13, 2025
31 checks passed
@simondeziel simondeziel deleted the idmapset-linux branch August 13, 2025 18:59
@simondeziel
Copy link
Member Author

With that PR, I wanted to squash the 6 integer overflow alerts that CodeQL found in that file. Despite not indicating the PR was achieving this, it seems like it did once merged into main: https://github.com/canonical/lxd/security/code-scanning?query=is%3Aclosed+branch%3Amain+path%3Alxd%2Fidmap%2Fidmapset_linux.go+tool%3ACodeQL+rule%3Ago%2Fincorrect-integer-conversion+

We have quite a few other alerts to tend to but slightly less than before :)

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.

2 participants