Git Product home page Git Product logo

Comments (6)

itsacoderepo avatar itsacoderepo commented on May 18, 2024 2

@sciencemanx

Current version of joern (v1.1.440) is handling x as a local.

Based on your initial code snippet, you should be able to query for x with:

joern> cpg.local.l
res4: List[Local] = List(
  Local(
    id -> 3074457345618258674L,
    closureBindingId -> None,
    code -> "int x",
    columnNumber -> None,
    dynamicTypeHintFullName -> ArraySeq(),
    lineNumber -> Some(value = 1),
    name -> "x",
    order -> 1,
    typeFullName -> "int"
  )
)

Closing..

from joern.

fabsx00 avatar fabsx00 commented on May 18, 2024

Yes, this should be handled. What do you mean by "shows no references to" exactly?

from joern.

sciencemanx avatar sciencemanx commented on May 18, 2024

@fabsx00 "shows no references to" means that "x" "int x" etc. does not exist in the cpg.zip database.

Additionally, I have found that while the database created from

typedef int size_t;
void *malloc(size_t x);

contains no information (or any reference to) malloc, the following does

typedef int size_t;
void *malloc(size_t x) {

}

from joern.

sciencemanx avatar sciencemanx commented on May 18, 2024

Therefore, it appears that any declarations are skipped while definitions are added to the database.

from joern.

GlassAndOneHalf avatar GlassAndOneHalf commented on May 18, 2024

Hi @sciencemanx

In regards to the first item, it seems that we only processes top-level identifier declarations if they are typedefs. See https://github.com/ShiftLeftSecurity/fuzzyc2cpg/blob/master/src/main/scala/io/shiftleft/fuzzyc2cpg/astnew/AstToCpgConverter.scala#L593-L594

At first glance, it seems we will need to change the existing code to create a LOCAL or IDENTIFIER node at the top level of the CPG. Alternatively we can start construction of the CPG with by beginning with a "global scope" pushed on the scope stack (currently the scope stack is initialized to be empty), and then add any corresponding nodes as before.

As for the second item (erased function declarations), with the code you have provided I am unable to reproduce the issue you are having:

Code:

typedef int size_t;
void *malloc(size_t x);

Query:

joern> cpg.method.l 
res12: List[Method] = List(
  Method(
    id -> 8L,
    name -> "malloc",
    fullName -> "malloc",
    isExternal -> false,
    signature -> "void*(size_t)",
    astParentType -> null,
    astParentFullName -> null,
    lineNumber -> Some(2),
    columnNumber -> Some(0),
    lineNumberEnd -> Some(2),
    columnNumberEnd -> Some(22),
    order -> null,
    hasMapping -> None,
    depthFirstOrder -> None,
    binarySignature -> None
  )
)

from joern.

GlassAndOneHalf avatar GlassAndOneHalf commented on May 18, 2024

See ShiftLeftSecurity/fuzzyc2cpg#156

from joern.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.