github-advanced-security[bot] commented on code in PR #639: URL: https://github.com/apache/syncope/pull/639#discussion_r1512714626
########## core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ProvisioningContext.java: ########## @@ -272,82 +257,39 @@ } @Bean - public SchedulerDBInit quartzDataSourceInit(final ProvisioningProperties provisioningProperties) { - SchedulerDBInit init = new SchedulerDBInit(); - init.setDataSource(masterDataSource); - - ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator(); - databasePopulator.setContinueOnError(true); - databasePopulator.setIgnoreFailedDrops(true); - databasePopulator.setSqlScriptEncoding(StandardCharsets.UTF_8.name()); - databasePopulator.setScripts(new ClassPathResource("/quartz/" + provisioningProperties.getQuartz().getSql())); - init.setDatabasePopulator(databasePopulator); - - return init; - } - - @DependsOn("quartzDataSourceInit") - @Lazy(false) - @Bean - public SchedulerFactoryBean scheduler(final ApplicationContext ctx, final ProvisioningProperties props) { - SchedulerFactoryBean scheduler = new SchedulerFactoryBean(); - scheduler.setAutoStartup(true); - scheduler.setApplicationContext(ctx); - scheduler.setWaitForJobsToCompleteOnShutdown(props.getQuartz().isWaitForJobsToCompleteOnShutdown()); - scheduler.setOverwriteExistingJobs(true); - scheduler.setDataSource(masterDataSource); - scheduler.setTransactionManager(domainTransactionManager); - scheduler.setJobFactory(new SyncopeSpringBeanJobFactory()); - - Properties quartzProperties = new Properties(); - quartzProperties.setProperty( - "org.quartz.scheduler.idleWaitTime", - String.valueOf(props.getQuartz().getIdleWaitTime())); - quartzProperties.setProperty( - "org.quartz.jobStore.misfireThreshold", - String.valueOf(props.getQuartz().getMisfireThreshold())); - quartzProperties.setProperty( - "org.quartz.jobStore.driverDelegateClass", - props.getQuartz().getDelegate().getName()); - quartzProperties.setProperty( - "org.quartz.jobStore.class", - "org.springframework.scheduling.quartz.LocalDataSourceJobStore"); - quartzProperties.setProperty("org.quartz.threadPool.makeThreadsDaemons", "true"); - quartzProperties.setProperty("org.quartz.scheduler.makeSchedulerThreadDaemon", "true"); - quartzProperties.setProperty("org.quartz.jobStore.isClustered", "true"); - quartzProperties.setProperty("org.quartz.jobStore.clusterCheckinInterval", "20000"); - quartzProperties.setProperty("org.quartz.scheduler.instanceName", "SyncopeClusteredScheduler"); - quartzProperties.setProperty("org.quartz.scheduler.instanceId", "AUTO"); - quartzProperties.setProperty("org.quartz.scheduler.jmx.export", "true"); - scheduler.setQuartzProperties(quartzProperties); - - return scheduler; + public SyncopeTaskScheduler taskScheduler(final ProvisioningProperties props, final JobStatusDAO jobStatusDAO) { + SimpleAsyncTaskScheduler taskScheduler = new SimpleAsyncTaskScheduler(); + taskScheduler.setVirtualThreads(true); + taskScheduler.setConcurrencyLimit(props.getScheduling().getPoolSize()); + taskScheduler.setTaskTerminationTimeout(props.getScheduling().getAwaitTerminationSeconds() * 1000); Review Comment: ## Result of multiplication cast to wider type Potential overflow in [int multiplication](1) before it is converted to long by use in an invocation context. [Show more details](https://github.com/apache/syncope/security/code-scanning/1526) ########## core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/spring/DomainRoutingDriver.java: ########## @@ -0,0 +1,126 @@ +/* + * 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.neo4j.spring; + +import java.util.concurrent.CompletionStage; +import org.apache.syncope.core.persistence.api.DomainHolder; +import org.apache.syncope.core.spring.security.AuthContextUtils; +import org.neo4j.driver.AuthToken; +import org.neo4j.driver.BaseSession; +import org.neo4j.driver.BookmarkManager; +import org.neo4j.driver.Driver; +import org.neo4j.driver.ExecutableQuery; +import org.neo4j.driver.Metrics; +import org.neo4j.driver.SessionConfig; +import org.neo4j.driver.types.TypeSystem; + +public class DomainRoutingDriver implements Driver { + + protected final DomainHolder<Driver> domainHolder; + + public DomainRoutingDriver(final DomainHolder<Driver> domainHolder) { + this.domainHolder = domainHolder; + } + + protected Driver delegate() { + return domainHolder.getDomains().computeIfAbsent(AuthContextUtils.getDomain(), domain -> { + throw new IllegalStateException("Could not find Driver for domain " + domain); + }); + } + + @Override + public ExecutableQuery executableQuery(final String query) { + return delegate().executableQuery(query); + } + + @Override + public BookmarkManager executableQueryBookmarkManager() { + return delegate().executableQueryBookmarkManager(); + } + + @Override + public boolean isEncrypted() { + return delegate().isEncrypted(); + } + + @Override + public <T extends BaseSession> T session( + final Class<T> sessionClass, + final SessionConfig sessionConfig, + final AuthToken sessionAuthToken) { + + return delegate().session(sessionClass, sessionConfig, sessionAuthToken); + } + + @Override + public void close() { + delegate().close(); + } + + @Override + public CompletionStage<Void> closeAsync() { + return delegate().closeAsync(); + } + + @Override + public Metrics metrics() { + return delegate().metrics(); + } + + @Override + public boolean isMetricsEnabled() { + return delegate().isMetricsEnabled(); + } + + @SuppressWarnings("deprecation") + @Override + public TypeSystem defaultTypeSystem() { + return delegate().defaultTypeSystem(); Review Comment: ## Deprecated method or constructor invocation Invoking [Driver.defaultTypeSystem](1) should be avoided because it has been deprecated. [Show more details](https://github.com/apache/syncope/security/code-scanning/1527) ########## core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/job/JobExecutionContext.java: ########## @@ -0,0 +1,62 @@ +/* + * 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.provisioning.api.job; + +import java.util.HashMap; +import java.util.Map; + +public class JobExecutionContext { + + private final String domain; + + private final String jobName; + + private final String executor; + + private final boolean dryRun; + + private final Map<String, Object> data = new HashMap<>(); + + public JobExecutionContext(final String domain, final String jobName, final String executor, final boolean dryRun) { + this.domain = domain; + this.jobName = jobName; + this.executor = executor; + this.dryRun = dryRun; + } + + public String getDomain() { + return domain; + } + + public String getJobName() { + return jobName; + } + + public String getExecutor() { + return executor; + } + + public boolean isDryRun() { + return dryRun; + } + + public Map<String, Object> getData() { Review Comment: ## Exposing internal representation getData exposes the internal representation stored in field data. The value may be modified [after this call to getData](1). getData exposes the internal representation stored in field data. The value may be modified [after this call to getData](2). getData exposes the internal representation stored in field data. The value may be modified [after this call to getData](3). getData exposes the internal representation stored in field data. The value may be modified [after this call to getData](4). getData exposes the internal representation stored in field data. The value may be modified [after this call to getData](5). getData exposes the internal representation stored in field data. The value may be modified [after this call to getData](6). getData exposes the internal representation stored in field data. The value may be modified [after this call to getData](7). [Show more details](https://github.com/apache/syncope/security/code-scanning/1528) -- 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