Uploaded image for project: 'Atlas'
  1. Atlas
  2. ATLAS-4652

Missing null check leading to NPE in isSoftReferenced method in AtlasStructDef

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 2.2.0
    • 3.0.0, 2.3.0
    • atlas-core
    • None

    Description

      The code inside isSoftReferenced method in AtlasStructDef class below:

         }}     {{@JsonIgnore

              public boolean isSoftReferenced() {

                  return this.options != null && }}{{          getOptions().containsKey(AtlasAttributeDef.ATTRDEF_OPTION_SOFT_REFERENCE) &&

                          getOptions().get(AtlasAttributeDef.ATTRDEF_OPTION_SOFT_REFERENCE).equals(STRING_TRUE);

      {{        }}}

       

      Since the null check is not performed, it can lead to NPE in typedef resolution.

       

      A sample typedef payload like the following can potentially trigger the NPE error in attribute resolution, i.e. EntityGraphRetriever.mapVertexToAttribute, where attribute.getAttributeDef().isSoftReferenced() is called

      {

        "businessMetadataDefs": [

          {

            "category": "BUSINESS_METADATA",

            "name": "bizType1",

            "description": "test",

            "attributeDefs": [

              {

                "name": "bizAttr1",

                "typeName": "string",

                "isOptional": true,

                "cardinality": "SINGLE",         

                "options":

      {                      *"isSoftReference": null,*               "maxStrLength": "50",             "applicableEntityTypes": "[\"Asset\"]"           }

               

              }

            ]

          }

        ]

      }

       

      It would be furthermore helpful to run SonarCube or FindBugs to determine any other incidences where this pattern of missing null check exists in Atlas codebase and address them. 

      Attachments

        1. ATLAS-4652.patch
          10 kB
          Madhan Neethiraj

        Activity

          People

            madhan Madhan Neethiraj
            srikvenk Srikanth Venkat
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: