Skip to content

Conversation

@max-leuthaeuser
Copy link
Contributor

This PR includes the following changes:

  • no creation of locals from assignments to type decl members
  • assignments to type decl members are now correctly attached to the constructor block
  • no creation of members from methods/functions under type decls
  • proper creation of call base for dynamic calls
  • proper creation of implicit self access to members from identifiers

There is no way to determine whether a call is a call to a static method/function at the moment. The SwiftParser does not provide that information. I will extend the utils handling compiler information for this purpose. This would go beyond the scope of this PR (its already large enough). Will do a follow up PR.

- no more local from assignment to type decl member
- assignment to type decl member is now correctly attached to  the constructor block
- no member from method/function under type decl
- proper call base
- implicit self access to member from identifier
@max-leuthaeuser max-leuthaeuser force-pushed the max/callAndMemberRework branch from b85667d to 21474f1 Compare November 7, 2025 05:34
@max-leuthaeuser max-leuthaeuser force-pushed the max/callAndMemberRework branch from 21474f1 to ac30297 Compare November 7, 2025 05:38
…thods

- simple call to static function detection
- self param for synthetic constructor methods
Copy link
Contributor

@ml86 ml86 left a comment

Choose a reason for hiding this comment

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

I did not see a test for a call to an extension method and also calls on protocols. If the are missing please add them.

Copy link
Contributor

@ml86 ml86 left a comment

Choose a reason for hiding this comment

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

Please also add a test where one class implements two protocols.

@ml86 ml86 self-requested a review November 17, 2025 09:00
@max-leuthaeuser
Copy link
Contributor Author

@maltek We lose https://github.com/ShiftLeftSecurity/codescience/blob/04601283b4c56be30aec56f735e46adc2022152b/sptestV2/expectations/swiftsrc2cpg-DVIA-v2/DVIA-v2.cpg.sptest.json#L7 with this PR, the other findings are all fine.
I guess one of the related policies need an update but I wasn't able to get it right. Could you have a look please?

@maltek
Copy link
Contributor

maltek commented Nov 18, 2025

@max-leuthaeuser max-leuthaeuser merged commit a81cb0b into master Nov 19, 2025
8 checks passed
@max-leuthaeuser max-leuthaeuser deleted the max/callAndMemberRework branch November 19, 2025 13:16
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.

4 participants