github-advanced-security[bot] commented on code in PR #1258:
URL: https://github.com/apache/syncope/pull/1258#discussion_r2694012285
##########
common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/request/GroupCR.java:
##########
@@ -129,16 +122,8 @@
this.groupOwner = groupOwner;
}
- public String getUDynMembershipCond() {
- return udynMembershipCond;
- }
-
- public void setUDynMembershipCond(final String uDynMembershipCond) {
- this.udynMembershipCond = uDynMembershipCond;
- }
-
- public Map<String, String> getADynMembershipConds() {
- return adynMembershipConds;
+ public Map<String, String> getDynMembershipConds() {
Review Comment:
## Exposing internal representation
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](1).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](2).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](3).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](4).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](5).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](6).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](7).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](8).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](9).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](10).
[Show more
details](https://github.com/apache/syncope/security/code-scanning/2494)
##########
core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/DerAttrHandler.java:
##########
@@ -81,7 +81,7 @@
* @param membership membership
* @return derived attribute values
*/
- Map<DerSchema, String> getValues(Groupable<?, ?, ?> any, Membership<?>
membership);
+ Map<String, String> getValues(Groupable<?, ?, ?> any, Membership<?>
membership);
Review Comment:
## Confusing overloading of methods
Method DerAttrHandler.getValues(..) could be confused with overloaded method
[getValues](1), since dispatch depends on static types.
[Show more
details](https://github.com/apache/syncope/security/code-scanning/2497)
##########
core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/RealmChecker.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.api.dao;
+
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+import org.apache.syncope.common.lib.types.EntityViolationType;
+import
org.apache.syncope.core.persistence.api.attrvalue.InvalidEntityException;
+import org.apache.syncope.core.persistence.api.entity.PlainAttr;
+import org.apache.syncope.core.persistence.api.entity.PlainSchema;
+import org.apache.syncope.core.persistence.api.entity.Realm;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.transaction.annotation.Transactional;
+
+public class RealmChecker {
+
+ protected static final Logger LOG =
LoggerFactory.getLogger(RealmChecker.class);
+
+ protected final PlainSchemaDAO plainSchemaDAO;
+
+ public RealmChecker(final PlainSchemaDAO plainSchemaDAO) {
+ this.plainSchemaDAO = plainSchemaDAO;
+ }
+
+ @Transactional(readOnly = true)
+ public void checkBeforeSave(final Realm realm) {
+ Set<String> allowed = realm.getAnyTypeClasses().stream().
+ flatMap(atc ->
atc.getPlainSchemas().stream()).map(PlainSchema::getKey).collect(Collectors.toSet());
+
+ for (PlainAttr attr : realm.getPlainAttrs()) {
+ String schema =
Optional.ofNullable(attr).map(PlainAttr::getSchema).orElse(null);
+ if (schema != null && !allowed.contains(schema)) {
+ throw new InvalidEntityException(
+ realm.getClass(),
+
EntityViolationType.InvalidPlainAttr.propertyPath("plainAttrs"),
+ schema + " not allowed for this instance");
+ }
+ }
+
+ // check UNIQUE constraints
+ realm.getPlainAttrs().stream().
+ filter(attr -> attr.getUniqueValue() != null).
+ forEach(attr -> {
+ if (plainSchemaDAO.existsPlainAttrUniqueValue(
+ realm.getKey(),
+ plainSchemaDAO.findById(attr.getSchema()).
+ orElseThrow(() -> new
NotFoundException("PlainSchema " + attr.getSchema())),
+ attr.getUniqueValue())) {
+
+ throw new DuplicateException("Duplicate value found
for "
+ + attr.getSchema() + "=" +
attr.getUniqueValue().getValueAsString());
+ } else {
+ LOG.debug("No duplicate value found for {}={}",
+ attr.getSchema(),
attr.getUniqueValue().getValueAsString());
Review Comment:
## Log Injection
This log entry depends on a [user-provided value](1).
This log entry depends on a [user-provided value](2).
[Show more
details](https://github.com/apache/syncope/security/code-scanning/2492)
##########
common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/to/GroupTO.java:
##########
@@ -137,8 +127,8 @@
this.dynamicAnyObjectMembershipCount = dynamicAnyObjectMembershipCount;
}
- public Map<String, String> getADynMembershipConds() {
- return adynMembershipConds;
+ public Map<String, String> getDynMembershipConds() {
Review Comment:
## Exposing internal representation
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](1).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](2).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](3).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](4).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](5).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](6).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](7).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](8).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](9).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](10).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](11).
[Show more
details](https://github.com/apache/syncope/security/code-scanning/2496)
##########
common/idrepo/lib/src/main/java/org/apache/syncope/common/lib/request/GroupUR.java:
##########
@@ -137,16 +130,8 @@
this.groupOwner = groupOwner;
}
- public String getUDynMembershipCond() {
- return udynMembershipCond;
- }
-
- public void setUDynMembershipCond(final String udynMembershipCond) {
- this.udynMembershipCond = udynMembershipCond;
- }
-
- public Map<String, String> getADynMembershipConds() {
- return adynMembershipConds;
+ public Map<String, String> getDynMembershipConds() {
Review Comment:
## Exposing internal representation
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](1).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](2).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](3).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](4).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](5).
getDynMembershipConds exposes the internal representation stored in field
dynMembershipConds. The value may be modified [after this call to
getDynMembershipConds](6).
[Show more
details](https://github.com/apache/syncope/security/code-scanning/2495)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]