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

Sync with upstream v4.0.29 #66

Draft
wants to merge 168 commits into
base: master
Choose a base branch
from
Draft

Sync with upstream v4.0.29 #66

wants to merge 168 commits into from

Conversation

tuxology
Copy link

@tuxology tuxology commented Aug 7, 2024

max-leuthaeuser and others added 30 commits May 29, 2024 14:54
…nio#4612)

Just some fixed MAX_BATCH_SIZE until we come up with something better.

Fixes: joernio#4611
…ariables (joernio#4617)

* Add reproducing test

* Add tests for new lambdas

* Never add Unknown node for captured variable

* Add todos to comments about lambda parameter capturing
* [python] prevent overtainting dictLiterals

* use allAssignmentTypes in isAssignment

* use methodFullNameExact instead of nameExact in isAssignment
As pointed out in joernio#4240, combining this nested immutable map-like structure has a quadratic performance, and the more performant strategy would be to use nested data-structures to merge.

For now, I've decided not to opt for a builder pattern, but rather keep the underlying structure mutable, and accessor methods return immutable structures.
)

This PR does two things:
1) DEBUG logs the frontend name, version and raw arguments passed down
2) INFO logs the CPG output path if not set explicitly by the user
Added a recursive aspect to the call type recovery if the receiver of the call is possibly recoverable (and it's receiver if that's a call and so on)
- log cpg creation for each file in DEBUG only instead of INFO
 - log the astgen path only once with INFO
 - removed logging that astgen runs now in the given input folder
- Fix last error token position if error token itself is semicolon,
  newline or EOF.
- Also log the parser exception message.
Moved parser logging of memory clearing from INFO to DEBUG
A common pattern in JavaScript is something like

```javascript
var foo = {};
foo.bar = {};
foo.bar.someFunc = function someFunc() {};

foo.bar.someFunc();
```

This PR adds a post-processing pass to find instances where the definition and the call live in the same file and to link them. This "common file" limitation aims to reduce false linking.
also to minify the diff for the flatgraph port
Allow the frontend to continue analysis if the type stubs for built-ins is missing.
The `new` operator can prefix an ordinary call, e.g.
```javascript
var Print = function(str) {
	console.log(str)
}

new Print("Hello")
```
The type recovery pass only considers object instantiations from type declarations on `new` calls, but this change allows it to consider functions too.

Other changes include adding constants for `:program` and `<operator>.new`
Added implicit self receiver to simple calls.
In ruby as for all other dynamic language there is no vtable and thus
only a single entry in the binding tables with name=="" and
signature=="".
This change moves the type/method identifier references for entities exportable from the script to prefix the respective entity at the definition.
this caused me some headaches as I had an old jar lying around there,
likely from a bisect session...
This change moves the type/method identifier references for entities exportable from the script to prefix the respective entity at the definition.
ICPPASTExpression.getEvaluation may fail throwing an unrecoverable exception in case of unresolved includes etc.
* Added `Member` nodes for each method, to relate to their respective bound `TypeDecl` nodes.
* Added a type decl for "fake methods" that include the methods and classes exported by the file
To simplify the call graph, methods resolved to the `Kernel` class are dispatched as static.

Additionally, replaced `__builtin` with `Kernel` to map more closely to Ruby's internals and implemented `MemberAccessCommandContext`.
max-leuthaeuser and others added 30 commits July 24, 2024 09:51
`.getArrayModifiers` may contain null values for empty array init
This may throw (FileSystemLoopException, or any other reason why this dir may not be readable).
We use Files.walkFileTree now. The only solution where a safe continue mechanism can be implemented.

Fixes: https://shiftleftinc.atlassian.net/browse/SEN-2976
- implicit this param for CPP functions
- identifiers that are actual member accesses are now transformed, e.g., this->varname if varname is a member and we are in the corresponding context
1. Added the support in the CfgCreator. A THROW control structure now
   breaks control flow.
2. Adjust c2cpg to generate such a control structure instead of a CALL
   node.
In this PR joernio#4807 the CFG for
`throw` statements was changes in the way that they have no outgoing CFG
edges. Since this might break assumptions of some CFG consuming code, we
now create outgoing CFG edges from `throw` statements to the method exit
nodes.
* [ruby] Initial commit for new Ast Printer, basic methods implemented

* [ruby] Initial AstPrinter finished

* [ruby] String parser tests working on new AstPrinter

* [ruby] ArrayParserTests, SingleAssignmentTests, BeginExpressionTests moved over to new AstPrinter for parsing tests

* [ruby] BooleanParserTests moved to new parser test

* [ruby] CaseConditionParserTests moved

* [ruby] ControlStructureParserTests moved

* [ruby] FieldAccess, HashLiteral, IndexAccess and InvocationWithoutParentheses parser tests moved

* [ruby] InvocationWithParentheses moved

* [ruby] MethodDef and ProcDef parser tests moved

* [ruby] Range, regex, require parser tests moved

* [ruby] Return and ternary parser tests moved

* [ruby] UnlessStmt parser tests moved

* [ruby] Ensure statement parser test moved

* [ruby] DoBlock parser tests moved

* [ruby] RescueClause parser tests moved

* [ruby] MultipleAssignment moved

* [ruby] ClassDecl moved

* [ruby] Module parser tests moved

* [ruby] Working on interpolations

* [ruby] Cleanup

* [ruby] Cleanup for PR

* [ruby] removed newMatch flag
* [ruby] Added handling for String interpolated array literals

* [ruby] Added type check in tests

* cleanup

* [ruby] Fixed parser tests with new parser test framework

* [ruby] removed if check on element content
* [ruby] handling added for command literal. Modelled as exec call

* [ruby] fixed failing parser test

* [ruby] Removed print

* [ruby] Added expanded command literal to new parser tests
Using the old SerializedCpg API hat no effect anymore.
* [ruby2cpg] Fix ImplicitRequirePass.

- Fix method lookup via AST edges. The approach of looking up module
  methods via is not possible at the execution time of the pass because
  AST is not yet linked.
  I replaced this buy a fullname based regex lookup.
  We should likely just change the execution time to after AST linking.

- The other changes are just for better readability and debugability.

* Address review remarks.

* Fix field access lookup.

We are only interested on those field accesses which operator on "self"
since those describe the exported/imported objects.
* [ruby] Fixed bracket assignments

* [ruby] Add parser test for BracketAssignment
joern-cli/frontends/csharpsrc2cpg/src/main/scala/io/joern/csharpsrc2cpg/astcreation/AstForStatementsCreator.scala
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.