github-advanced-security[bot] commented on code in PR #594:
URL: https://github.com/apache/syncope/pull/594#discussion_r1444987177


##########
core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPolicyDAO.java:
##########
@@ -89,39 +95,71 @@
 
     protected final EntityCacheDAO entityCacheDAO;
 
+    protected final EntityManager entityManager;
+
     public JPAPolicyDAO(
             final RealmDAO realmDAO,
             final ExternalResourceDAO resourceDAO,
             final CASSPClientAppDAO casSPClientAppDAO,
             final OIDCRPClientAppDAO oidcRPClientAppDAO,
             final SAML2SPClientAppDAO saml2SPClientAppDAO,
-            final EntityCacheDAO entityCacheDAO) {
+            final EntityCacheDAO entityCacheDAO,
+            final EntityManager entityManager) {
 
         this.realmDAO = realmDAO;
         this.resourceDAO = resourceDAO;
         this.casSPClientAppDAO = casSPClientAppDAO;
         this.oidcRPClientAppDAO = oidcRPClientAppDAO;
         this.saml2SPClientAppDAO = saml2SPClientAppDAO;
         this.entityCacheDAO = entityCacheDAO;
+        this.entityManager = entityManager;
+    }
+
+    @Override
+    public Optional<? extends Policy> findById(final String key) {
+        return Optional.ofNullable(entityManager.find(AbstractPolicy.class, 
key));
+    }
+
+    @Override
+    public <T extends Policy> Optional<T> findById(final String key, final 
Class<T> reference) {
+        TypedQuery<T> query = entityManager.createQuery(
+                "SELECT e FROM " + 
getEntityReference(reference).getSimpleName() + " e WHERE e.id=:key", 
reference);
+        query.setParameter("key", key);
+
+        T result = null;
+        try {
+            result = query.getSingleResult();
+        } catch (Exception e) {
+            LOG.debug("{} with key {} not found", reference.getName(), key, e);

Review Comment:
   ## Insertion of sensitive information into log files
   
   This [potentially sensitive information](1) is written to a log file.
   
   [Show more 
details](https://github.com/apache/syncope/security/code-scanning/1440)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@syncope.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to