2016-08-23 55 views
1

我已對我的項目運行復選標記安全檢查,並得到了A2-Broken身份驗證和會話管理對於「cstmt.execute()」行的衝突。 我知道它向我展示了owasp提到的前10名中的漏洞之一。如何解決A2-損壞的身份驗證和會話管理警告?

需要幫助瞭解我的代碼出了什麼問題,以及如何解決這個問題。

public int editUser(UserBean userParams) throws CustomException{ 

     String query = DbConstants.EDITUSER_PROC; 
     Connection con = null; 
     CallableStatement cstmt=null; 
     OracleConnection oracleConnection = null; 
     ARRAY arrayToPass =null; 
     int status = 0; 
     String cntrctId = null; 
     String keyAcc = null; 
     String roles = null; 
     String pnl = null; 

     if(!"Y".equals(userParams.getAllContrctFlag())){ 
      cntrctId = Arrays.toString(userParams.getContractId().toArray()).replace("[", "").replace("]", "").trim(); 
      keyAcc = Arrays.toString(userParams.getKeyAcName().toArray()).replace("[", "").replace("]", "").trim(); 
     } 

     roles = Arrays.toString(userParams.getUserRole().toArray()).replace("[", "").replace("]", "").trim(); 
     pnl = Arrays.toString(userParams.getDefaultPnl().toArray()).replace("[", "").replace("]", "").trim(); 

     logger.debug("Edit User cntrctId,KeyAcc, roles : "+cntrctId+"\n"+keyAcc+"\n"+roles); 

     try { 
      con = jdbcTemplate.getDataSource().getConnection(); 

      if(con.isWrapperFor(OracleConnection.class)){ 
       oracleConnection =con.unwrap(OracleConnection.class);      
       ArrayDescriptor ad = ArrayDescriptor.createDescriptor("RELTK_WIDGET_USER_TYPE",oracleConnection); 
       arrayToPass = new ARRAY(ad, oracleConnection, userParams.getWidgets().toArray()); 
      }else{ 
       ArrayDescriptor ad = ArrayDescriptor.createDescriptor("RELTK_WIDGET_USER_TYPE",con); 
       arrayToPass = new ARRAY(ad, con, userParams.getWidgets().toArray()); 
      } 

      cstmt = con.prepareCall(query); 
      cstmt.setString(1, userParams.getSso()); 
      cstmt.setString(2, roles); 
      cstmt.setString(3, userParams.getUserType()); 
      cstmt.setString(4, keyAcc); 
      cstmt.setString(5, cntrctId); 
      cstmt.setString(6, userParams.getAdminSso()); 
      cstmt.setString(7, pnl); 
      cstmt.setString(8, userParams.getAllContrctFlag()); 
      cstmt.setObject(9, arrayToPass); 
      cstmt.execute(); 
      status = 1; 
     }catch(Exception ex){ 
      logger.error("Error while getting Edit User ---> "+ex.getMessage()); 
      status = 0; 
      throw new CustomException(ex.getMessage()); 
     }finally{ 
      if(cstmt != null){ 
       try { 
        cstmt.close(); 
       } catch (SQLException se) { 
        logger.error("Error while getting Edit User(close connection) ---> "+se.getMessage()); 
       } 
      } 
      if(con != null){ 
       try { 
        con.close(); 
       } catch (SQLException se) { 
        logger.error("Error while getting Edit User(close connection) ---> "+se.getMessage()); 
       } 
      } 
     } 
     return status; 
    }  

以上存在於DAO層的方法並獲得由另一個本發明的方法在提供服務級別,其接受REST呼叫並輸入作爲JSON轉換JSON來的UserBean對象並傳遞作爲參數來editUser

回答

1

的Checkmarx工具發現稱爲在沒有用戶授權標誌的情況下訪問數據庫。

如果在您的情況下授權過程正確完成(例如通過使用roles參數或getAdminSso()方法),則可以將此結果標記爲「不可利用」。