From 8828149c9475d2411a2feeb6aaaad08fec3ce562 Mon Sep 17 00:00:00 2001 From: trydofor Date: Tue, 13 Feb 2024 15:59:51 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=F0=9F=92=9A=20use=20qodana=20and=20summary?= =?UTF-8?q?=20#204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/qodana.yml | 20 ------------------ .github/workflows/release.yml | 40 ++++++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 28 deletions(-) delete mode 100644 .github/workflows/qodana.yml diff --git a/.github/workflows/qodana.yml b/.github/workflows/qodana.yml deleted file mode 100644 index 4822eeb0..00000000 --- a/.github/workflows/qodana.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Qodana -on: - workflow_dispatch: - push: - branches: - - 'main' - -jobs: - qodana: - runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - checks: write - steps: - - uses: actions/checkout@v4 - - name: 'Qodana Scan' - uses: JetBrains/qodana-action@v2023.3 - env: - QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1f6ae3d4..904383d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,4 @@ name: Release-To-OssRh -run-name: Release ${{ github.ref_name }} by @${{ github.event_name }} on: workflow_dispatch: @@ -28,6 +27,11 @@ on: - INFO - WARN - ERROR + applyQodanaScan: + description: 'apply Qodana Scan?' + default: true + type: boolean + required: false deployOssrh: description: 'deploy to ossrh?' default: true @@ -42,6 +46,10 @@ jobs: release: name: Release to Sonatype runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + checks: write env: MAVEN_OPTS: -Xmx2g LOG_LEVEL: ${{ inputs.testLoggerLevel || 'INFO' }} @@ -73,31 +81,43 @@ jobs: - name: Maven settings.xml id: settings run: | + echo "## env and var" >> "$GITHUB_STEP_SUMMARY" + echo "" >> "$GITHUB_STEP_SUMMARY" JAVA_HOME=$(asdf where java) + echo "- JAVA_HOME=$JAVA_HOME" >> "$GITHUB_STEP_SUMMARY" echo "JAVA_HOME=$JAVA_HOME" >> "$GITHUB_OUTPUT" + echo "- GIT_BRANCH=$(git branch --show-current)" >> "$GITHUB_STEP_SUMMARY" echo "GIT_BRANCH=$(git branch --show-current)" >> "$GITHUB_OUTPUT" _opt=$(git describe --tags --exact-match 2>/dev/null || true) if [ "$_opt" != "" ]; then _opt="-Drevision=$_opt" - echo "MVN_REVISION=$_opt" + echo "- MVN_REVISION=$_opt" >> "$GITHUB_STEP_SUMMARY" echo "MVN_REVISION=$_opt" >> "$GITHUB_OUTPUT" fi _ver=$(mvn --quiet --non-recursive -DforceStdout -Dexpression=project.version $_opt help:evaluate) - echo "WINGS_VERSION=$_ver" + echo "- WINGS_VERSION=$_ver" >> "$GITHUB_STEP_SUMMARY" echo "WINGS_VERSION=$_ver" >> "$GITHUB_OUTPUT" _cov=${{ inputs.testCoverReport || github.event_name == 'push' }} - echo "MVN_COVERAGE=$_cov" + echo "- MVN_COVERAGE=$_cov" >> "$GITHUB_STEP_SUMMARY" echo "MVN_COVERAGE=$_cov" >> "$GITHUB_OUTPUT" _drh=${{ inputs.deployOssrh || github.event_name == 'release' }} - echo "MVN_DEPLOYRH=$_drh" + echo "- MVN_DEPLOYRH=$_drh" >> "$GITHUB_STEP_SUMMARY" echo "MVN_DEPLOYRH=$_drh" >> "$GITHUB_OUTPUT" - mvn -v - git --no-pager log --graph -10 --pretty=format:'%H - %ai %d %s' + _qod=${{ inputs.applyQodanaScan || 'false' }} + echo "- QODANA_SCAN=$_qod" >> "$GITHUB_STEP_SUMMARY" + echo "QODANA_SCAN=$_qod" >> "$GITHUB_OUTPUT" + + echo "## mvn and git" >> "$GITHUB_STEP_SUMMARY" + echo "" >> "$GITHUB_STEP_SUMMARY" + echo '```text' >> "$GITHUB_STEP_SUMMARY" + mvn -v >> "$GITHUB_STEP_SUMMARY" + git --no-pager log --graph -10 --pretty=format:'%H - %ai %d %s' >> "$GITHUB_STEP_SUMMARY" + echo '```' >> "$GITHUB_STEP_SUMMARY" mkdir -p ~/.m2 cat > ~/.m2/settings.xml << "EOF" @@ -112,7 +132,11 @@ jobs: EOF - + - name: Qodana Scan + uses: JetBrains/qodana-action@v2023.3 + if: steps.settings.outputs.QODANA_SCAN == 'true' + env: + QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} ## report if not release - name: Test Coverage ${{ steps.settings.outputs.WINGS_VERSION }} ${{ steps.settings.outputs.GIT_BRANCH }} if: steps.settings.outputs.MVN_COVERAGE == 'true' From 50da5d0e056886023d9e2b03419104ff6194651a Mon Sep 17 00:00:00 2001 From: trydofor Date: Wed, 14 Feb 2024 15:29:43 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=94=A5=20inspect=20code=20#184?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 5 +- observe/scripts/wings-starter.sh | 4 +- observe/scripts/wings-testing.sh | 8 +-- .../service/impl/TinyMailServiceImpl.java | 48 +++++++------- .../service/impl/TinyTaskConfServiceImpl.java | 66 +++++++++---------- .../codegen/ConstantEnumGenerator.java | 47 +++++++------ .../codegen/ConstantNaviGenerator.java | 3 +- .../faceless/flywave/SchemaFulldumpManager.kt | 22 +++---- .../faceless/flywave/SchemaJournalManager.kt | 55 ++++++++-------- .../faceless/flywave/SqlStatementParser.kt | 2 +- .../database/WingsTableCudHandler.java | 14 ++++ .../database/jooq/WingsJooqDaoAliasImpl.java | 11 ++-- .../bean/FacelessJooqConfiguration.java | 2 +- .../database/helper/JournalJdbcHelper.java | 6 +- .../spring/boot/WingsAutoConfigProcessor.java | 3 +- .../spring/boot/WingsEnabledCondition.java | 2 +- .../WingsHazelcastCacheCustomizer.java | 6 -- .../slardar/serialize/KryoHazelcast.java | 11 +--- .../conf/WingsHttpPermitConfigurer.java | 29 ++++---- .../spring/help/SecurityConfigHelper.java | 39 +---------- .../app/conf/TestSecurityConfiguration.java | 14 ++-- .../concur/impl/DebounceInterceptor.java | 1 - .../request/FakeHttpServletRequest.java | 3 +- .../SlardarDomainExtendConfiguration.java | 16 +++-- .../bean/SlardarOkhttpWebConfiguration.java | 1 + .../spring-servlet-server-79.properties | 2 +- .../wings-conf/wings-cookie-79.properties | 2 +- .../wings-domain-extend-79.properties | 2 +- .../slardar/cache/cache2k/NullsCache2k.java | 3 +- .../slardar/cache/spring/NullsCache.java | 3 +- .../httprest/okhttp/OkHttpClientBuilder.java | 4 +- .../wings/slardar/notice/DingTalkNotice.java | 2 +- .../bean/SlardarAsyncConfiguration.java | 12 ++-- .../bean/SlardarEventConfiguration.java | 4 +- .../perm/impl/WarlockPermServiceImpl.java | 6 +- .../perm/impl/WarlockRoleServiceImpl.java | 6 +- .../handler/AccessFailureHandler.java | 3 +- .../session/NonceTokenSessionHelper.java | 3 - .../WarlockSecurityConfConfiguration.java | 36 +++++----- .../spring/prop/WarlockEnabledProp.java | 2 +- 40 files changed, 237 insertions(+), 271 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 904383d2..993893e7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,5 @@ name: Release-To-OssRh +run-name: Release ${{ github.ref_name }} by @${{ github.event_name }} on: workflow_dispatch: @@ -81,7 +82,7 @@ jobs: - name: Maven settings.xml id: settings run: | - echo "## env and var" >> "$GITHUB_STEP_SUMMARY" + echo "# env and var" >> "$GITHUB_STEP_SUMMARY" echo "" >> "$GITHUB_STEP_SUMMARY" JAVA_HOME=$(asdf where java) echo "- JAVA_HOME=$JAVA_HOME" >> "$GITHUB_STEP_SUMMARY" @@ -112,7 +113,7 @@ jobs: echo "- QODANA_SCAN=$_qod" >> "$GITHUB_STEP_SUMMARY" echo "QODANA_SCAN=$_qod" >> "$GITHUB_OUTPUT" - echo "## mvn and git" >> "$GITHUB_STEP_SUMMARY" + echo "# mvn and git" >> "$GITHUB_STEP_SUMMARY" echo "" >> "$GITHUB_STEP_SUMMARY" echo '```text' >> "$GITHUB_STEP_SUMMARY" mvn -v >> "$GITHUB_STEP_SUMMARY" diff --git a/observe/scripts/wings-starter.sh b/observe/scripts/wings-starter.sh index 3ba94ee4..0eb56232 100755 --- a/observe/scripts/wings-starter.sh +++ b/observe/scripts/wings-starter.sh @@ -574,8 +574,8 @@ case "$ARGS_RUN" in # shellcheck disable=SC2009 mvs=$(ps -o vsz "$cid" | grep -v VSZ | numfmt --grouping) echo -e "\033[37;42;1mINFO: ps -o rss -o vsz $cid \033[0m" - echo -e "Resident (RSS) = $(printf "%*s" 12 $mrs) Kb" - echo -e "Virtual (VSZ) = $(printf "%*s" 12 $mvs) Kb" + echo -e "Resident (RSS) = $(printf '%*s' 12 $mrs) Kb" + echo -e "Virtual (VSZ) = $(printf '%*s' 12 $mvs) Kb" if [[ "$USER_RUN" == "$USER" ]]; then echo -e "\033[37;42;1mINFO: $(which jstat) -gcutil $cid 1000 3 \033[0m" diff --git a/observe/scripts/wings-testing.sh b/observe/scripts/wings-testing.sh index af36f15d..baf5eeba 100644 --- a/observe/scripts/wings-testing.sh +++ b/observe/scripts/wings-testing.sh @@ -69,10 +69,10 @@ fi # ############## echo "=====================" pwd -echo MAVEN_OPTS=$MAVEN_OPTS -echo LOG_LEVEL=$LOG_LEVEL -echo TEST_VERBOSE=$TEST_VERBOSE -echo COVERALLS_DRYRUN=$COVERALLS_DRYRUN +echo "MAVEN_OPTS=$MAVEN_OPTS" +echo "LOG_LEVEL=$LOG_LEVEL" +echo "TEST_VERBOSE=$TEST_VERBOSE" +echo "COVERALLS_DRYRUN=$COVERALLS_DRYRUN" echo "FROM STEP $_step TO RUN" echo "=====================" set -e diff --git a/radiant/tiny-mail/src/main/java/pro/fessional/wings/tiny/mail/service/impl/TinyMailServiceImpl.java b/radiant/tiny-mail/src/main/java/pro/fessional/wings/tiny/mail/service/impl/TinyMailServiceImpl.java index f8b811c8..63ffa4dc 100644 --- a/radiant/tiny-mail/src/main/java/pro/fessional/wings/tiny/mail/service/impl/TinyMailServiceImpl.java +++ b/radiant/tiny-mail/src/main/java/pro/fessional/wings/tiny/mail/service/impl/TinyMailServiceImpl.java @@ -170,18 +170,18 @@ public long emit(long id, boolean retry, boolean check) { @Override @SuppressWarnings("DuplicatedCode") - public long save(@NotNull TinyMailPlain message) { - final String conf = message.getConf(); + public long save(@NotNull TinyMailPlain msg) { + final String conf = msg.getConf(); final TinyMailConfig config = mailConfigProvider.bynamedConfig(conf); AssertArgs.notNull(config, "mail conf={} not found", conf); final WinMailSender po = new WinMailSender(); - final boolean isNew = message.getId() == null || message.getId() <= 0; + final boolean isNew = msg.getId() == null || msg.getId() <= 0; final long id; final RunMode rm = RuntimeMode.getRunMode(); final String crm = rm == RunMode.Nothing ? "" : rm.name().toLowerCase(); - final LocalDateTime md = message.getDate(); + final LocalDateTime md = msg.getDate(); if (isNew) { id = lightIdService.getId(winMailSenderDao.getTable()); // Optimist Lock @@ -193,32 +193,32 @@ public long save(@NotNull TinyMailPlain message) { po.setSumDone(0); } else { - id = message.getId(); - Null.notNull(message.getNextSend(), po::setNextSend); + id = msg.getId(); + Null.notNull(msg.getNextSend(), po::setNextSend); } po.setId(id); - po.setMailApps(toString(message.getApps(), appName)); - po.setMailRuns(toString(message.getRuns(), crm)); - po.setMailConf(message.getConf()); - po.setMailFrom(toString(message.getFrom(), config.getFrom())); - po.setMailTo(toString(message.getTo(), config.getTo())); - po.setMailCc(toString(message.getCc(), config.getCc())); - po.setMailBcc(toString(message.getBcc(), config.getBcc())); - po.setMailReply(toString(message.getReply(), config.getReply())); - po.setMailSubj(message.getSubject()); - po.setMailText(message.getContent()); - po.setMailHtml(BoxedCastUtil.orElse(message.getHtml(), config.getHtml())); - po.setMailFile(toStringMap(message.getAttachment())); - po.setMailMark(message.getMark()); + po.setMailApps(toString(msg.getApps(), appName)); + po.setMailRuns(toString(msg.getRuns(), crm)); + po.setMailConf(msg.getConf()); + po.setMailFrom(toString(msg.getFrom(), config.getFrom())); + po.setMailTo(toString(msg.getTo(), config.getTo())); + po.setMailCc(toString(msg.getCc(), config.getCc())); + po.setMailBcc(toString(msg.getBcc(), config.getBcc())); + po.setMailReply(toString(msg.getReply(), config.getReply())); + po.setMailSubj(msg.getSubject()); + po.setMailText(msg.getContent()); + po.setMailHtml(BoxedCastUtil.orElse(msg.getHtml(), config.getHtml())); + po.setMailFile(toStringMap(msg.getAttachment())); + po.setMailMark(msg.getMark()); po.setMailDate(md); - Null.notNull(message.getMaxFail(), po::setMaxFail); - Null.notNull(message.getMaxDone(), po::setMaxDone); + Null.notNull(msg.getMaxFail(), po::setMaxFail); + Null.notNull(msg.getMaxDone(), po::setMaxDone); - Null.notNull(message.getRefType(), po::setRefType); - Null.notNull(message.getRefKey1(), po::setRefKey1); - Null.notNull(message.getRefKey2(), po::setRefKey2); + Null.notNull(msg.getRefType(), po::setRefType); + Null.notNull(msg.getRefKey1(), po::setRefKey1); + Null.notNull(msg.getRefKey2(), po::setRefKey2); // try to check message format final TinyMailMessage tms = makeMailMessage(config, po, null); diff --git a/radiant/tiny-task/src/main/java/pro/fessional/wings/tiny/task/service/impl/TinyTaskConfServiceImpl.java b/radiant/tiny-task/src/main/java/pro/fessional/wings/tiny/task/service/impl/TinyTaskConfServiceImpl.java index 0758f05f..f7dfc191 100644 --- a/radiant/tiny-task/src/main/java/pro/fessional/wings/tiny/task/service/impl/TinyTaskConfServiceImpl.java +++ b/radiant/tiny-task/src/main/java/pro/fessional/wings/tiny/task/service/impl/TinyTaskConfServiceImpl.java @@ -355,51 +355,51 @@ private boolean updateProp(TaskerProp prop, String key, long id) { @NotNull private WinTaskDefine genWinTaskDefine(TaskerProp prop, String key) { - WinTaskDefine po = new WinTaskDefine(); + WinTaskDefine wtd = new WinTaskDefine(); - po.setEnabled(prop.isEnabled()); - po.setAutorun(prop.isAutorun()); - po.setVersion(prop.getVersion()); - po.setPropkey(key); + wtd.setEnabled(prop.isEnabled()); + wtd.setAutorun(prop.isAutorun()); + wtd.setVersion(prop.getVersion()); + wtd.setPropkey(key); - po.setTaskerBean(prop.getTaskerBean()); - po.setTaskerPara(prop.getTaskerPara()); - po.setTaskerName(prop.getTaskerName()); - po.setTaskerFast(prop.isTaskerFast()); + wtd.setTaskerBean(prop.getTaskerBean()); + wtd.setTaskerPara(prop.getTaskerPara()); + wtd.setTaskerName(prop.getTaskerName()); + wtd.setTaskerFast(prop.isTaskerFast()); final String apps = prop.getTaskerApps(); - po.setTaskerApps(isEmpty(apps) ? appName : apps); + wtd.setTaskerApps(isEmpty(apps) ? appName : apps); final String runs = prop.getTaskerRuns(); if (isEmpty(runs)) { final RunMode rm = RuntimeMode.getRunMode(); - po.setTaskerRuns(rm == RunMode.Nothing ? "" : rm.name().toLowerCase()); + wtd.setTaskerRuns(rm == RunMode.Nothing ? "" : rm.name().toLowerCase()); } else { - po.setTaskerRuns(runs); + wtd.setTaskerRuns(runs); } - po.setNoticeBean(prop.getNoticeBean()); - po.setNoticeWhen(prop.getNoticeWhen()); - po.setNoticeConf(prop.getNoticeConf()); - - po.setTimingZone(prop.getTimingZone()); - po.setTimingType(prop.getTimingType()); - po.setTimingCron(prop.getTimingCron()); - po.setTimingIdle(prop.getTimingIdle()); - po.setTimingRate(prop.getTimingRate()); - po.setTimingMiss(prop.getTimingMiss()); - po.setTimingBeat(prop.getTimingBeat()); - - po.setDuringFrom(prop.getDuringFrom()); - po.setDuringStop(prop.getDuringStop()); - po.setDuringExec(prop.getDuringExec()); - po.setDuringFail(prop.getDuringFail()); - po.setDuringDone(prop.getDuringDone()); - po.setDuringBoot(prop.getDuringBoot()); - - po.setResultKeep(prop.getResultKeep()); - return po; + wtd.setNoticeBean(prop.getNoticeBean()); + wtd.setNoticeWhen(prop.getNoticeWhen()); + wtd.setNoticeConf(prop.getNoticeConf()); + + wtd.setTimingZone(prop.getTimingZone()); + wtd.setTimingType(prop.getTimingType()); + wtd.setTimingCron(prop.getTimingCron()); + wtd.setTimingIdle(prop.getTimingIdle()); + wtd.setTimingRate(prop.getTimingRate()); + + wtd.setTimingMiss(prop.getTimingMiss()); + wtd.setTimingBeat(prop.getTimingBeat()); + wtd.setDuringFrom(prop.getDuringFrom()); + wtd.setDuringStop(prop.getDuringStop()); + wtd.setDuringExec(prop.getDuringExec()); + wtd.setDuringFail(prop.getDuringFail()); + wtd.setDuringDone(prop.getDuringDone()); + wtd.setDuringBoot(prop.getDuringBoot()); + + wtd.setResultKeep(prop.getResultKeep()); + return wtd; } private T fetchProp(Class claz, Function cond) { diff --git a/wings/faceless-codegen/src/main/java/pro/fessional/wings/faceless/codegen/ConstantEnumGenerator.java b/wings/faceless-codegen/src/main/java/pro/fessional/wings/faceless/codegen/ConstantEnumGenerator.java index eaa3425e..d086c40c 100644 --- a/wings/faceless-codegen/src/main/java/pro/fessional/wings/faceless/codegen/ConstantEnumGenerator.java +++ b/wings/faceless-codegen/src/main/java/pro/fessional/wings/faceless/codegen/ConstantEnumGenerator.java @@ -4,6 +4,7 @@ import lombok.Data; import lombok.NoArgsConstructor; import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import pro.fessional.meepo.Meepo; @@ -145,7 +146,7 @@ public static void generate(File src, String pkg, Collection nowFiles = new HashSet<>(); File dst = new File(src, pkg.replace('.', '/')); - dst.mkdirs(); + boolean ignore = dst.mkdirs(); Map javaFiles = mergeJava(pkg, pojos, filter); @@ -189,27 +190,9 @@ public static void generate(File src, String pkg, Collection mergeJava(String pkg, Collection pos, Map filter) { - final Map> temp = pos + Map> enums = filterEnums(filter, pos .stream() - .collect(Collectors.groupingBy(ConstantEnum::getType)); - - Map> enums = new TreeMap<>(temp); - final Map> incs = new TreeMap<>(); - for (Map.Entry en : filter.entrySet()) { - if (Boolean.TRUE.equals(en.getValue())) { - final List vs = enums.get(en.getKey()); - if (vs != null) { - incs.put(en.getKey(), vs); - } - } - else { - enums.remove(en.getKey()); - } - } - - if (!incs.isEmpty()) { - enums = incs; - } + .collect(Collectors.groupingBy(ConstantEnum::getType))); Map javaFiles = new HashMap<>(); int count = 1; @@ -288,6 +271,28 @@ else if (c > 127) { return javaFiles; } + @NotNull + private static Map> filterEnums(Map filter, Map> temp) { + Map> enums = new TreeMap<>(temp); + final Map> incs = new TreeMap<>(); + for (Map.Entry en : filter.entrySet()) { + if (Boolean.TRUE.equals(en.getValue())) { + final List vs = enums.get(en.getKey()); + if (vs != null) { + incs.put(en.getKey(), vs); + } + } + else { + enums.remove(en.getKey()); + } + } + + if (!incs.isEmpty()) { + enums = incs; + } + return enums; + } + private static boolean isSuper(ConstantEnum it) { return it.getId() % 100 == 0; } diff --git a/wings/faceless-codegen/src/main/java/pro/fessional/wings/faceless/codegen/ConstantNaviGenerator.java b/wings/faceless-codegen/src/main/java/pro/fessional/wings/faceless/codegen/ConstantNaviGenerator.java index dc960ea6..66b318c5 100644 --- a/wings/faceless-codegen/src/main/java/pro/fessional/wings/faceless/codegen/ConstantNaviGenerator.java +++ b/wings/faceless-codegen/src/main/java/pro/fessional/wings/faceless/codegen/ConstantNaviGenerator.java @@ -10,7 +10,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.text.MessageFormat; import java.time.LocalDate; import java.util.ArrayList; import java.util.Collection; @@ -51,7 +50,7 @@ public void generate(String javaName, String prefixCode, Collection(tables.size + table.size) val temp = LinkedList(tables) for (t in table) { - if (t.startsWith(prefix)) { + if (t.startsWith(Prefix)) { spec.add(t) continue } @@ -73,7 +73,7 @@ class SchemaFulldumpManager( } } if (!only && temp.isNotEmpty()) { - spec.add(prefix) + spec.add(Prefix) spec.addAll(temp.sorted()) } spec @@ -91,7 +91,7 @@ class SchemaFulldumpManager( val regexSlots = LinkedHashMap>(regexp.size) for (it in regexp) { when { - it.startsWith(prefix) -> regexSlots[it.toRegex(RegexOption.LITERAL)] = arrayListOf(it.trim()) + it.startsWith(Prefix) -> regexSlots[it.toRegex(RegexOption.LITERAL)] = arrayListOf(it.trim()) else -> regexSlots[it.toRegex(RegexOption.IGNORE_CASE)] = arrayListOf() } } @@ -112,7 +112,7 @@ class SchemaFulldumpManager( if (!only && temp.isNotEmpty()) { ArrayList(grpd.size + temp.size + 1).apply { addAll(grpd) - add(prefix) + add(Prefix) addAll(temp.sorted()) } } else { @@ -157,7 +157,7 @@ class SchemaFulldumpManager( } else -> { - buf.write("$prefix ${sql.table} ${sql.sqlType}") + buf.write("$Prefix ${sql.table} ${sql.sqlType}") buf.write("\n") buf.write("${sql.sqlText};") buf.write("\n\n") @@ -166,12 +166,12 @@ class SchemaFulldumpManager( } if (trgs.isNotEmpty()) { - buf.write("$prefix TRIGGER") + buf.write("$Prefix TRIGGER") buf.write("\n\n") buf.write("DELIMITER \$\$") buf.write("\n\n") for (sql in trgs) { - buf.write("$prefix ${sql.table} ${sql.sqlType}\n${sql.sqlText} \$\$\n\n") + buf.write("$Prefix ${sql.table} ${sql.sqlType}\n${sql.sqlText} \$\$\n\n") } buf.write("DELIMITER ;\n") } @@ -196,7 +196,7 @@ class SchemaFulldumpManager( val tables = schemaDefinitionLoader.showTables(database) for (table in filterSorter(tables)) { - if (table.startsWith(prefix)) { + if (table.startsWith(Prefix)) { log.info("[dumpDdl] insert comment, {}", table) result.add(SqlString(table, SqlType.StrComment, table.trim())) continue @@ -242,7 +242,7 @@ class SchemaFulldumpManager( val tables = schemaDefinitionLoader.showTables(database) val builder = StringBuilder() for (table in filterSorter(tables)) { - if (table.startsWith(prefix)) { + if (table.startsWith(Prefix)) { log.info("[dumpRec] insert comment, {}", table) result.add(SqlString(table, SqlType.StrComment, table.trim())) continue @@ -283,7 +283,7 @@ class SchemaFulldumpManager( private fun appendRevision(result: ArrayList, tmpl: SimpleJdbcTemplate) = try { tmpl.query("SELECT revision, apply_dt FROM sys_schema_version WHERE apply_dt >'1000-01-01' order by revision desc limit 1") { val sb = StringBuilder() - sb.append(prefix) + sb.append(Prefix) sb.append(" revision=") sb.append(it.getString("revision")) sb.append(", apply_dt=") diff --git a/wings/faceless-flywave/src/main/kotlin/pro/fessional/wings/faceless/flywave/SchemaJournalManager.kt b/wings/faceless-flywave/src/main/kotlin/pro/fessional/wings/faceless/flywave/SchemaJournalManager.kt index 1811608e..6d3cc0b6 100644 --- a/wings/faceless-flywave/src/main/kotlin/pro/fessional/wings/faceless/flywave/SchemaJournalManager.kt +++ b/wings/faceless-flywave/src/main/kotlin/pro/fessional/wings/faceless/flywave/SchemaJournalManager.kt @@ -338,7 +338,6 @@ class SchemaJournalManager( WHERE table_name = ? """.trimIndent() } - isUpdate -> { """ SELECT @@ -349,7 +348,6 @@ class SchemaJournalManager( WHERE table_name = ? """.trimIndent() } - isDelete -> { """ SELECT @@ -360,7 +358,6 @@ class SchemaJournalManager( WHERE table_name = ? """.trimIndent() } - else -> { throw RuntimeException("unsupported event $event") } @@ -371,29 +368,35 @@ class SchemaJournalManager( } else { "'1000-01-01 00:00:00.000'" } - val updateSql = if (isInsert) { - """ - UPDATE $schemaJournalTable SET - log_insert = $logDate, - commit_id = ? - WHERE table_name = ? - """.trimIndent() - } else if (isUpdate) { - """ - UPDATE $schemaJournalTable SET - log_update = $logDate, - commit_id = ? - WHERE table_name = ? - """.trimIndent() - } else if (isDelete) { - """ - UPDATE $schemaJournalTable SET - log_delete = $logDate, - commit_id = ? - WHERE table_name = ? - """.trimIndent() - } else { - throw RuntimeException("unsupported event $event") + + val updateSql = when { + isInsert -> { + """ + UPDATE $schemaJournalTable SET + log_insert = $logDate, + commit_id = ? + WHERE table_name = ? + """.trimIndent() + } + isUpdate -> { + """ + UPDATE $schemaJournalTable SET + log_update = $logDate, + commit_id = ? + WHERE table_name = ? + """.trimIndent() + } + isDelete -> { + """ + UPDATE $schemaJournalTable SET + log_delete = $logDate, + commit_id = ? + WHERE table_name = ? + """.trimIndent() + } + else -> { + throw RuntimeException("unsupported event $event") + } } val model = HashMap() diff --git a/wings/faceless-flywave/src/main/kotlin/pro/fessional/wings/faceless/flywave/SqlStatementParser.kt b/wings/faceless-flywave/src/main/kotlin/pro/fessional/wings/faceless/flywave/SqlStatementParser.kt index 084939b9..36483921 100644 --- a/wings/faceless-flywave/src/main/kotlin/pro/fessional/wings/faceless/flywave/SqlStatementParser.kt +++ b/wings/faceless-flywave/src/main/kotlin/pro/fessional/wings/faceless/flywave/SqlStatementParser.kt @@ -11,7 +11,7 @@ interface SqlStatementParser { sealed class SqlType { data class Plain(val table: String, val rename: String = "") : SqlType() data class Shard(val table: String) : SqlType() - object Other : SqlType() + data object Other : SqlType() } /** diff --git a/wings/faceless-jooq/src/main/java/pro/fessional/wings/faceless/database/WingsTableCudHandler.java b/wings/faceless-jooq/src/main/java/pro/fessional/wings/faceless/database/WingsTableCudHandler.java index 13d8e0da..e1150351 100644 --- a/wings/faceless-jooq/src/main/java/pro/fessional/wings/faceless/database/WingsTableCudHandler.java +++ b/wings/faceless-jooq/src/main/java/pro/fessional/wings/faceless/database/WingsTableCudHandler.java @@ -4,8 +4,10 @@ import org.jooq.Table; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.function.Consumer; import java.util.function.Supplier; /** @@ -52,6 +54,18 @@ default void handle(@NotNull Class source, @NotNull Cud cud, @NotNull Table source, @NotNull Cud cud, @NotNull Table table, @NotNull Consumer>> field) { + handle(source, cud, table.getName(), field); + } + + default void handle(@NotNull Class source, @NotNull Cud cud, @NotNull String table, @NotNull Consumer>> field) { + handle(source, cud, table, () -> { + Map> map = new HashMap<>(); + field.accept(map); + return map; + }); + } + default void handle(@NotNull Class source, @NotNull Cud cud, @NotNull String table, @NotNull Map> field) { handle(source, cud, table, () -> field); } diff --git a/wings/faceless-jooq/src/main/java/pro/fessional/wings/faceless/database/jooq/WingsJooqDaoAliasImpl.java b/wings/faceless-jooq/src/main/java/pro/fessional/wings/faceless/database/jooq/WingsJooqDaoAliasImpl.java index 9ea539c7..147b0437 100644 --- a/wings/faceless-jooq/src/main/java/pro/fessional/wings/faceless/database/jooq/WingsJooqDaoAliasImpl.java +++ b/wings/faceless-jooq/src/main/java/pro/fessional/wings/faceless/database/jooq/WingsJooqDaoAliasImpl.java @@ -231,11 +231,12 @@ public Loader batchLoad(Collection records, boolean ignoreOrReplace) { DSLContext dsl = ctx(); LoaderOptionsStep ldi = dsl.loadInto(table); if (ignoreOrReplace) { - ldi.onDuplicateKeyIgnore(); + ldi = ldi.onDuplicateKeyIgnore(); } else { - ldi.onDuplicateKeyUpdate(); + ldi = ldi.onDuplicateKeyUpdate(); } + try { return ldi.loadRecords(records) .fields(table.fields()) @@ -307,8 +308,6 @@ private int insertInto(P pojo, boolean ignoreOrReplace, JournalDiff diff) { } else { -// RowCountQuery query = WingsJooqUtil.replaceInto(record); -// return dsl.execute(query); rc = dsl.insertInto(table) .columns(fields) .values(values) @@ -424,7 +423,7 @@ public int mergeInto(T table, P pojo, Field... updateFields) { for (int i = 0; i < updLen; i++) { vals[i + fldLen] = r.get(updateFields[i]); } - batch.bind(vals); + batch = batch.bind(vals); } return batch.execute(); @@ -683,7 +682,7 @@ public int mergeInto(T table, P pojo, Field... updateFields) { for (Field uf : whereFields) { vals[off++] = r.get(uf); } - batch.bind(vals); + batch = batch.bind(vals); } return batch.execute(); diff --git a/wings/faceless-jooq/src/main/java/pro/fessional/wings/faceless/spring/bean/FacelessJooqConfiguration.java b/wings/faceless-jooq/src/main/java/pro/fessional/wings/faceless/spring/bean/FacelessJooqConfiguration.java index f5001761..780fb33c 100644 --- a/wings/faceless-jooq/src/main/java/pro/fessional/wings/faceless/spring/bean/FacelessJooqConfiguration.java +++ b/wings/faceless-jooq/src/main/java/pro/fessional/wings/faceless/spring/bean/FacelessJooqConfiguration.java @@ -70,7 +70,7 @@ public DefaultConfigurationCustomizer jooqWingsConfigCustomizer( .withRenderGroupConcatMaxLenSessionVariable(config.isRenderGroupConcat()) // .withParseDialect(SQLDialect.MYSQL) .withRenderTable(config.getRenderTable()); - ; + log.info("FacelessJooq conf jooq setting, dialect=" + settings.getParseDialect()); if (config.isConverter()) { diff --git a/wings/faceless/src/main/java/pro/fessional/wings/faceless/database/helper/JournalJdbcHelper.java b/wings/faceless/src/main/java/pro/fessional/wings/faceless/database/helper/JournalJdbcHelper.java index e98dbff3..19e1eade 100644 --- a/wings/faceless/src/main/java/pro/fessional/wings/faceless/database/helper/JournalJdbcHelper.java +++ b/wings/faceless/src/main/java/pro/fessional/wings/faceless/database/helper/JournalJdbcHelper.java @@ -148,7 +148,7 @@ public static String getFieldName(String name) { } // //// - private static void checkWhere(String where) { + public static void checkWhere(String where) { if (where == null || where.isEmpty()) { throw new IllegalArgumentException("where clause is empty"); } @@ -161,9 +161,9 @@ private static void checkWhere(String where) { } } - private static void checkTableName(String table) { + public static void checkTableName(String table) { if (table == null) throw new NullPointerException("table is null"); - if (table.contains(" ") || table.contains("\t") || table.contains("\r") || table.contains("\n") || table.contains("=")) { + if (table.contains(" ") || table.contains("\t") || table.contains("\r") || table.contains("\n") || table.contains("=") || table.contains(";")) { throw new IllegalArgumentException("table is may be sql-injected"); } } diff --git a/wings/silencer/src/main/java/pro/fessional/wings/silencer/spring/boot/WingsAutoConfigProcessor.java b/wings/silencer/src/main/java/pro/fessional/wings/silencer/spring/boot/WingsAutoConfigProcessor.java index b9168e7f..876e17d6 100644 --- a/wings/silencer/src/main/java/pro/fessional/wings/silencer/spring/boot/WingsAutoConfigProcessor.java +++ b/wings/silencer/src/main/java/pro/fessional/wings/silencer/spring/boot/WingsAutoConfigProcessor.java @@ -12,6 +12,7 @@ import org.springframework.core.io.Resource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.util.StringUtils; +import pro.fessional.mirana.best.DummyBlock; import pro.fessional.mirana.cast.StringCastUtil; import pro.fessional.mirana.i18n.LocaleResolver; import pro.fessional.mirana.i18n.ZoneIdResolver; @@ -431,7 +432,7 @@ private LinkedHashSet scanWingsResource(MutablePropertySources sou path = path.replace("classpath:", "classpath*:"); } else if (path.startsWith("file:") || path.startsWith("classpath*:")) { - // skip + DummyBlock.empty(); } else { // 6. any non-`classpath:`,`classpath*:` will be scanned as `file:` diff --git a/wings/silencer/src/main/java/pro/fessional/wings/silencer/spring/boot/WingsEnabledCondition.java b/wings/silencer/src/main/java/pro/fessional/wings/silencer/spring/boot/WingsEnabledCondition.java index 301216b8..98530c7e 100644 --- a/wings/silencer/src/main/java/pro/fessional/wings/silencer/spring/boot/WingsEnabledCondition.java +++ b/wings/silencer/src/main/java/pro/fessional/wings/silencer/spring/boot/WingsEnabledCondition.java @@ -65,7 +65,7 @@ public class WingsEnabledCondition extends SpringBootCondition { public static void reset() { Uninit = true; ErrorMap.clear(); - ErrorMap.clear(); + PrefixMap.clear(); EnableMap.clear(); } diff --git a/wings/slardar-hazel-caching/src/main/java/pro/fessional/wings/slardar/cache/hazelcast/WingsHazelcastCacheCustomizer.java b/wings/slardar-hazel-caching/src/main/java/pro/fessional/wings/slardar/cache/hazelcast/WingsHazelcastCacheCustomizer.java index 574277bb..d4aa6b3c 100644 --- a/wings/slardar-hazel-caching/src/main/java/pro/fessional/wings/slardar/cache/hazelcast/WingsHazelcastCacheCustomizer.java +++ b/wings/slardar-hazel-caching/src/main/java/pro/fessional/wings/slardar/cache/hazelcast/WingsHazelcastCacheCustomizer.java @@ -25,12 +25,6 @@ public class WingsHazelcastCacheCustomizer implements HazelcastConfigCustomizer public void customize(Config config) { final Map mapCnf = config.getMapConfigs(); - /* - final SlardarCacheProp.Conf common = slardarCacheProp.getCommon(); - checkMapConf(config, mapCnf, "default", common.getMaxLive(), - common.getMaxIdle(), common.getMaxSize()); - */ - // check level for (Map.Entry entry : cacheProp.getLevel().entrySet()) { final SlardarCacheProp.Conf lvl = entry.getValue(); diff --git a/wings/slardar-hazel-caching/src/main/java/pro/fessional/wings/slardar/serialize/KryoHazelcast.java b/wings/slardar-hazel-caching/src/main/java/pro/fessional/wings/slardar/serialize/KryoHazelcast.java index e974855b..6f370f94 100644 --- a/wings/slardar-hazel-caching/src/main/java/pro/fessional/wings/slardar/serialize/KryoHazelcast.java +++ b/wings/slardar-hazel-caching/src/main/java/pro/fessional/wings/slardar/serialize/KryoHazelcast.java @@ -13,19 +13,10 @@ * @author trydofor * @since 2021-06-09 */ -public class KryoHazelcast implements StreamSerializer/*, HazelcastInstanceAware */ { +public class KryoHazelcast implements StreamSerializer { public static final int TYPE_ID = 1979_01_30; - /* - private HazelcastInstance hazelcastInstance; - - @Override - public void setHazelcastInstance(HazelcastInstance ins) { - this.hazelcastInstance = ins; - } - */ - @Override public void write(ObjectDataOutput out, @NotNull Object object) throws IOException { final byte[] bytes = KryoSimple.writeClassAndObject(object); diff --git a/wings/slardar-sprint/src/main/java/pro/fessional/wings/slardar/spring/conf/WingsHttpPermitConfigurer.java b/wings/slardar-sprint/src/main/java/pro/fessional/wings/slardar/spring/conf/WingsHttpPermitConfigurer.java index 5e7094cd..a69d9c37 100644 --- a/wings/slardar-sprint/src/main/java/pro/fessional/wings/slardar/spring/conf/WingsHttpPermitConfigurer.java +++ b/wings/slardar-sprint/src/main/java/pro/fessional/wings/slardar/spring/conf/WingsHttpPermitConfigurer.java @@ -2,10 +2,8 @@ import lombok.SneakyThrows; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; -import org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer; import pro.fessional.wings.slardar.spring.help.SecurityConfigHelper; /** @@ -20,34 +18,39 @@ public WingsHttpPermitConfigurer permitCorsAll() { return this; } + @SneakyThrows @Contract("->this") public WingsHttpPermitConfigurer permitLogin() { - requestMatchers(SecurityConfigHelper.loginAntPaths()).permitAll(); + getBuilder().authorizeHttpRequests( + c -> c.requestMatchers(SecurityConfigHelper.loginAntPaths()).permitAll() + ); return this; } + @SneakyThrows @Contract("->this") public WingsHttpPermitConfigurer permitOAuth2() { - requestMatchers(SecurityConfigHelper.oauth2AntPaths()).permitAll(); + getBuilder().authorizeHttpRequests( + c -> c.requestMatchers(SecurityConfigHelper.oauth2AntPaths()).permitAll() + ); return this; } + @SneakyThrows @Contract("->this") public WingsHttpPermitConfigurer permitSwagger() { - requestMatchers(SecurityConfigHelper.swaggerAntPaths()).permitAll(); + getBuilder().authorizeHttpRequests( + c -> c.requestMatchers(SecurityConfigHelper.swaggerAntPaths()).permitAll() + ); return this; } + @SneakyThrows @Contract("->this") public WingsHttpPermitConfigurer permitTest() { - requestMatchers(SecurityConfigHelper.testAntPaths()).permitAll(); + getBuilder().authorizeHttpRequests( + c -> c.requestMatchers(SecurityConfigHelper.testAntPaths()).permitAll() + ); return this; } - - @SneakyThrows - @NotNull - public AuthorizeHttpRequestsConfigurer.AuthorizedUrl requestMatchers(String... paths) { - final HttpSecurity http = getBuilder(); - return http.authorizeHttpRequests().requestMatchers(paths); - } } diff --git a/wings/slardar-sprint/src/main/java/pro/fessional/wings/slardar/spring/help/SecurityConfigHelper.java b/wings/slardar-sprint/src/main/java/pro/fessional/wings/slardar/spring/help/SecurityConfigHelper.java index 3c5fda97..43c96466 100644 --- a/wings/slardar-sprint/src/main/java/pro/fessional/wings/slardar/spring/help/SecurityConfigHelper.java +++ b/wings/slardar-sprint/src/main/java/pro/fessional/wings/slardar/spring/help/SecurityConfigHelper.java @@ -1,12 +1,8 @@ package pro.fessional.wings.slardar.spring.help; -import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.springframework.context.ApplicationContext; -import org.springframework.security.config.Customizer; import org.springframework.security.config.annotation.web.AbstractRequestMatcherRegistry; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.web.util.matcher.RequestMatcher; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsConfigurationSource; @@ -14,8 +10,6 @@ import pro.fessional.wings.slardar.security.WingsUserDetailsService; import pro.fessional.wings.slardar.servlet.request.FakeHttpServletRequest; import pro.fessional.wings.slardar.spring.conf.WingsBindAuthnConfigurer; -import pro.fessional.wings.slardar.spring.conf.WingsBindLoginConfigurer; -import pro.fessional.wings.slardar.spring.conf.WingsHttpPermitConfigurer; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; @@ -35,38 +29,6 @@ */ public class SecurityConfigHelper { - /** - *
-     * protected void configure(HttpSecurity http) throws Exception {
-     *     http
-     *         .apply(wingsPermit())
-     *             .permitAllCors(true)
-     *             .and()
-     *         ...;
-     * }
-     * 
- */ - @NotNull - public static HttpHelper http() { - return new HttpHelper(); - } - - public static class HttpHelper extends AbstractHttpConfigurer { - @Contract("_->this") - public HttpHelper httpPermit(Customizer customizer) throws Exception { - final WingsHttpPermitConfigurer conf = getBuilder().apply(new WingsHttpPermitConfigurer()); - customizer.customize(conf); - return this; - } - - @Contract("_->this") - public HttpHelper bindLogin(Customizer customizer) throws Exception { - final WingsBindLoginConfigurer conf = getBuilder().apply(new WingsBindLoginConfigurer()); - customizer.customize(conf); - return this; - } - } - public static class MatcherHelper extends AbstractRequestMatcherRegistry { private final Consumer> matchersConsumer; @@ -84,6 +46,7 @@ protected MatcherHelper chainRequestMatchers(List requestMatcher public static MatcherHelper of(ApplicationContext context, AtomicReference ref) { return new MatcherHelper(context, it -> ref.set(it.get(0))); } + public static MatcherHelper of(ApplicationContext context, RequestMatcher[] ref) { return new MatcherHelper(context, it -> it.toArray(ref)); } diff --git a/wings/slardar-sprint/src/test/java/pro/fessional/wings/slardar/app/conf/TestSecurityConfiguration.java b/wings/slardar-sprint/src/test/java/pro/fessional/wings/slardar/app/conf/TestSecurityConfiguration.java index 6cd8a711..8ef5a66d 100644 --- a/wings/slardar-sprint/src/test/java/pro/fessional/wings/slardar/app/conf/TestSecurityConfiguration.java +++ b/wings/slardar-sprint/src/test/java/pro/fessional/wings/slardar/app/conf/TestSecurityConfiguration.java @@ -5,9 +5,13 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; +import org.springframework.security.config.annotation.web.configurers.RequestCacheConfigurer; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.util.matcher.AntPathRequestMatcher; import pro.fessional.mirana.data.Null; +import pro.fessional.wings.slardar.spring.conf.WingsBindLoginConfigurer; +import pro.fessional.wings.slardar.spring.conf.WingsHttpPermitConfigurer; import pro.fessional.wings.slardar.spring.help.SecurityConfigHelper; @@ -39,12 +43,11 @@ public class TestSecurityConfiguration { @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { log.info("config HttpSecurity"); - http.apply(SecurityConfigHelper.http()) - .httpPermit(conf -> conf + http.with(new WingsHttpPermitConfigurer(), conf -> conf .permitCorsAll() .permitTest() ) - .bindLogin(conf -> conf + .with(new WingsBindLoginConfigurer(), conf -> conf .loginPage("/user/login.json") .loginProcessingUrl("/*/login-proc.json") .usernameParameter("username") @@ -53,7 +56,6 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti .failureHandler((request, response, exception) -> log.info("failureHandler")) .bindAuthTypeToEnums("user", Null.Enm) ) - .and() .authorizeHttpRequests(conf -> conf .requestMatchers(new AntPathRequestMatcher("/authed/*", null)).authenticated() ) @@ -75,8 +77,8 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti // .exceptionHandling(conf -> conf // .accessDeniedHandler() // ) - .requestCache().disable() - .csrf().disable(); + .requestCache(RequestCacheConfigurer::disable) + .csrf(AbstractHttpConfigurer::disable); return http.build(); } } diff --git a/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/concur/impl/DebounceInterceptor.java b/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/concur/impl/DebounceInterceptor.java index 0c99b930..9b4f6dfb 100644 --- a/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/concur/impl/DebounceInterceptor.java +++ b/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/concur/impl/DebounceInterceptor.java @@ -117,7 +117,6 @@ public boolean preHandle(@NotNull HttpServletRequest request, } @Override - @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") public void afterCompletion(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler, Exception ex) { diff --git a/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/servlet/request/FakeHttpServletRequest.java b/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/servlet/request/FakeHttpServletRequest.java index 93c8cbb2..76ee91d4 100644 --- a/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/servlet/request/FakeHttpServletRequest.java +++ b/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/servlet/request/FakeHttpServletRequest.java @@ -5,7 +5,6 @@ import jakarta.servlet.RequestDispatcher; import jakarta.servlet.ServletConnection; import jakarta.servlet.ServletContext; -import jakarta.servlet.ServletException; import jakarta.servlet.ServletInputStream; import jakarta.servlet.ServletRequest; import jakarta.servlet.ServletResponse; @@ -141,7 +140,7 @@ public void login(String username, String password) { } @Override - public void logout() throws ServletException { + public void logout() { } @Override diff --git a/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/spring/bean/SlardarDomainExtendConfiguration.java b/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/spring/bean/SlardarDomainExtendConfiguration.java index 78956fc5..d7b12945 100644 --- a/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/spring/bean/SlardarDomainExtendConfiguration.java +++ b/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/spring/bean/SlardarDomainExtendConfiguration.java @@ -2,6 +2,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; @@ -11,6 +12,7 @@ import pro.fessional.mirana.text.Wildcard; import pro.fessional.wings.silencer.spring.boot.ConditionalWingsEnabled; import pro.fessional.wings.slardar.domainx.DefaultDomainRequestMatcher; +import pro.fessional.wings.slardar.domainx.DomainRequestMatcher; import pro.fessional.wings.slardar.domainx.WingsDomainExtendFilter; import pro.fessional.wings.slardar.spring.prop.DomainExtendProp; import pro.fessional.wings.slardar.spring.prop.SlardarEnabledProp; @@ -49,6 +51,13 @@ public WingsDomainExtendFilter wingsDomainExtendFilter(DomainExtendProp config, hostMatcher.put(key, ls); } + DomainRequestMatcher requestMatcher = buildDomainRequestMatcher(config, context); + + return new WingsDomainExtendFilter(hostMatcher, requestMatcher); + } + + @NotNull + private static DomainRequestMatcher buildDomainRequestMatcher(DomainExtendProp config, ApplicationContext context) { String prefix = config.getPrefix(); if (!prefix.endsWith("/")) { prefix = prefix + "/"; @@ -62,11 +71,6 @@ public WingsDomainExtendFilter wingsDomainExtendFilter(DomainExtendProp config, return handlerMappings; }; - DefaultDomainRequestMatcher requestMatcher = new DefaultDomainRequestMatcher(prefix, - config.getOtherUrl(), config.getCacheSize(), supplier); - - return new WingsDomainExtendFilter( - hostMatcher, - requestMatcher); + return new DefaultDomainRequestMatcher(prefix, config.getOtherUrl(), config.getCacheSize(), supplier); } } diff --git a/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/spring/bean/SlardarOkhttpWebConfiguration.java b/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/spring/bean/SlardarOkhttpWebConfiguration.java index 6f4a16ed..a1f15666 100644 --- a/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/spring/bean/SlardarOkhttpWebConfiguration.java +++ b/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/spring/bean/SlardarOkhttpWebConfiguration.java @@ -16,6 +16,7 @@ /** * @author trydofor * @link RestTemplate Customization + * @link Deprecate OkHttp3Client * @see RestTemplateAutoConfiguration#RestTemplateAutoConfiguration() * @since 2020-05-22 */ diff --git a/wings/slardar-webmvc/src/main/resources/wings-conf/spring-servlet-server-79.properties b/wings/slardar-webmvc/src/main/resources/wings-conf/spring-servlet-server-79.properties index 19d3d9b7..bc3863ec 100644 --- a/wings/slardar-webmvc/src/main/resources/wings-conf/spring-servlet-server-79.properties +++ b/wings/slardar-webmvc/src/main/resources/wings-conf/spring-servlet-server-79.properties @@ -9,7 +9,7 @@ spring.lifecycle.timeout-per-shutdown-phase=30s spring.servlet.multipart.max-file-size=-1 spring.servlet.multipart.max-request-size=-1 -## Assume 8 cores, 16G, 30ms per response. undertow better than tomcat +## 8C16G, 30ms per response. undertow is better than tomcat ## tomcat server.tomcat.max-connections=10000 server.tomcat.threads.max=1000 diff --git a/wings/slardar-webmvc/src/main/resources/wings-conf/wings-cookie-79.properties b/wings/slardar-webmvc/src/main/resources/wings-conf/wings-cookie-79.properties index e5b56624..6f58edc9 100644 --- a/wings/slardar-webmvc/src/main/resources/wings-conf/wings-cookie-79.properties +++ b/wings/slardar-webmvc/src/main/resources/wings-conf/wings-cookie-79.properties @@ -2,7 +2,7 @@ ## Cookie prefix, empty by default. wings.slardar.cookie.prefix= -## cookie alias, affected by the prefix, eg. +## cookie alias, affected by the prefix, e.g. ## `session`=`o_0`, `session` eventually is `${prefix}o_0` #wings.slardar.cookie.alias[session]=o_0 diff --git a/wings/slardar-webmvc/src/main/resources/wings-conf/wings-domain-extend-79.properties b/wings/slardar-webmvc/src/main/resources/wings-conf/wings-domain-extend-79.properties index a2b4503c..6ffff198 100644 --- a/wings/slardar-webmvc/src/main/resources/wings-conf/wings-domain-extend-79.properties +++ b/wings/slardar-webmvc/src/main/resources/wings-conf/wings-domain-extend-79.properties @@ -8,5 +8,5 @@ wings.slardar.domain-extend.prefix=/domain/ #wings.slardar.domain-extend.host[trydofor]=*.trydofor.com, trydofor.com ## specified domain url that is not automatically detected. -## ant match style, eg. `other-url`=`/trydofor/b/c.html` +## ant match style, e.g. `other-url`=`/trydofor/b/c.html` #wings.slardar.domain-extend.other-url=/trydofor/b/c.html, diff --git a/wings/slardar/src/main/java/pro/fessional/wings/slardar/cache/cache2k/NullsCache2k.java b/wings/slardar/src/main/java/pro/fessional/wings/slardar/cache/cache2k/NullsCache2k.java index 5f99f37f..bce2be1b 100644 --- a/wings/slardar/src/main/java/pro/fessional/wings/slardar/cache/cache2k/NullsCache2k.java +++ b/wings/slardar/src/main/java/pro/fessional/wings/slardar/cache/cache2k/NullsCache2k.java @@ -3,6 +3,7 @@ import org.cache2k.Cache; import org.cache2k.extra.spring.SpringCache2kCache; import org.jetbrains.annotations.NotNull; +import pro.fessional.mirana.best.DummyBlock; import java.util.concurrent.Callable; @@ -56,7 +57,7 @@ public void put(@NotNull Object key, Object value) { nulls.put(key, Boolean.TRUE); } else { - // skip null + DummyBlock.empty(); } } else { diff --git a/wings/slardar/src/main/java/pro/fessional/wings/slardar/cache/spring/NullsCache.java b/wings/slardar/src/main/java/pro/fessional/wings/slardar/cache/spring/NullsCache.java index a42e9d80..8c460c95 100644 --- a/wings/slardar/src/main/java/pro/fessional/wings/slardar/cache/spring/NullsCache.java +++ b/wings/slardar/src/main/java/pro/fessional/wings/slardar/cache/spring/NullsCache.java @@ -2,6 +2,7 @@ import org.jetbrains.annotations.NotNull; import org.springframework.cache.Cache; +import pro.fessional.mirana.best.DummyBlock; import pro.fessional.wings.slardar.cache.cache2k.WingsCache2k; import java.util.concurrent.Callable; @@ -73,7 +74,7 @@ public void put(@NotNull Object key, Object value) { nulls.put(key, Boolean.TRUE); } else { - // skip null + DummyBlock.empty(); } } else { diff --git a/wings/slardar/src/main/java/pro/fessional/wings/slardar/httprest/okhttp/OkHttpClientBuilder.java b/wings/slardar/src/main/java/pro/fessional/wings/slardar/httprest/okhttp/OkHttpClientBuilder.java index e7510b00..d2afdc98 100644 --- a/wings/slardar/src/main/java/pro/fessional/wings/slardar/httprest/okhttp/OkHttpClientBuilder.java +++ b/wings/slardar/src/main/java/pro/fessional/wings/slardar/httprest/okhttp/OkHttpClientBuilder.java @@ -33,13 +33,11 @@ public static Builder springBuilder() { return SpringBuilder != null ? SpringBuilder : staticBuilder(); } - @SuppressWarnings("KotlinInternalInJava") public static void sslTrustAll(Builder builder) { builder.sslSocketFactory(SslTrustAll.SSL_SOCKET_FACTORY, SslTrustAll.X509_TRUST_MANAGER) .hostnameVerifier(SslTrustAll.HOSTNAME_VERIFIER); } - - @SuppressWarnings("KotlinInternalInJava") + public static void cookieHost(Builder builder) { builder.cookieJar(new OkHttpHostCookie()); } diff --git a/wings/slardar/src/main/java/pro/fessional/wings/slardar/notice/DingTalkNotice.java b/wings/slardar/src/main/java/pro/fessional/wings/slardar/notice/DingTalkNotice.java index 3473d41f..b35e3e5a 100644 --- a/wings/slardar/src/main/java/pro/fessional/wings/slardar/notice/DingTalkNotice.java +++ b/wings/slardar/src/main/java/pro/fessional/wings/slardar/notice/DingTalkNotice.java @@ -143,7 +143,7 @@ public boolean send(DingTalkConf config, String subject, String content) { log.debug("ding-talk post message, host={}, text={}", host, message); String dr = config.getDryrun(); - if (dr != null && !dr.isEmpty() && subject.startsWith(dr)) { + if (dr != null && !dr.isEmpty() && subject != null && subject.startsWith(dr)) { log.info("ding-talk dryrun. subject={}, message={}", subject, message); return true; } diff --git a/wings/slardar/src/main/java/pro/fessional/wings/slardar/spring/bean/SlardarAsyncConfiguration.java b/wings/slardar/src/main/java/pro/fessional/wings/slardar/spring/bean/SlardarAsyncConfiguration.java index 0412e1e3..74f91af9 100644 --- a/wings/slardar/src/main/java/pro/fessional/wings/slardar/spring/bean/SlardarAsyncConfiguration.java +++ b/wings/slardar/src/main/java/pro/fessional/wings/slardar/spring/bean/SlardarAsyncConfiguration.java @@ -7,8 +7,8 @@ import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration; import org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration; import org.springframework.boot.autoconfigure.task.TaskSchedulingProperties; -import org.springframework.boot.task.TaskExecutorBuilder; -import org.springframework.boot.task.TaskSchedulerBuilder; +import org.springframework.boot.task.ThreadPoolTaskExecutorBuilder; +import org.springframework.boot.task.ThreadPoolTaskSchedulerBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.task.AsyncTaskExecutor; @@ -48,7 +48,7 @@ public class SlardarAsyncConfiguration { @Bean(name = DEFAULT_TASK_EXECUTOR_BEAN_NAME) @ConditionalWingsEnabled - public Executor taskExecutor(TaskExecutorBuilder builder) { + public Executor taskExecutor(ThreadPoolTaskExecutorBuilder builder) { final ThreadPoolTaskExecutor executor = builder.build(); executor.initialize(); log.info("Slardar spring-bean taskExecutor via ttlExecutor, prefix=" + executor.getThreadNamePrefix()); @@ -57,7 +57,7 @@ public Executor taskExecutor(TaskExecutorBuilder builder) { @Bean(name = APPLICATION_TASK_EXECUTOR_BEAN_NAME) @ConditionalWingsEnabled - public AsyncTaskExecutor applicationTaskExecutor(TaskExecutorBuilder builder) { + public AsyncTaskExecutor applicationTaskExecutor(ThreadPoolTaskExecutorBuilder builder) { final ThreadPoolTaskExecutor executor = builder.build(); executor.initialize(); final Executor ttlExecutor = TtlExecutors.getTtlExecutor(executor); @@ -68,7 +68,7 @@ public AsyncTaskExecutor applicationTaskExecutor(TaskExecutorBuilder builder) { // Do NOT use @Primary to avoid overwriting the @Async thread pool. @Bean(name = DEFAULT_TASK_SCHEDULER_BEAN_NAME) @ConditionalWingsEnabled - public ThreadPoolTaskScheduler taskScheduler(TaskSchedulerBuilder builder) { + public ThreadPoolTaskScheduler taskScheduler(ThreadPoolTaskSchedulerBuilder builder) { final TtlThreadPoolTaskScheduler scheduler = new TtlThreadPoolTaskScheduler(); final TtlThreadPoolTaskScheduler bean = builder.configure(scheduler); log.info("Slardar spring-bean taskScheduler via TtlThreadPoolTaskScheduler, prefix=" + bean.getThreadNamePrefix()); @@ -80,7 +80,7 @@ public ThreadPoolTaskScheduler taskScheduler(TaskSchedulerBuilder builder) { @ConditionalWingsEnabled public ThreadPoolTaskScheduler slardarHeavyScheduler(SlardarAsyncProp prop) { final TtlThreadPoolTaskScheduler scheduler = new TtlThreadPoolTaskScheduler(); - TaskSchedulerBuilder builder = new TaskSchedulerBuilder(); + ThreadPoolTaskSchedulerBuilder builder = new ThreadPoolTaskSchedulerBuilder(); final TaskSchedulingProperties heavy = prop.getHeavy(); builder = builder.poolSize(heavy.getPool().getSize()); TaskSchedulingProperties.Shutdown shutdown = heavy.getShutdown(); diff --git a/wings/slardar/src/main/java/pro/fessional/wings/slardar/spring/bean/SlardarEventConfiguration.java b/wings/slardar/src/main/java/pro/fessional/wings/slardar/spring/bean/SlardarEventConfiguration.java index cd4c9776..1b56ae71 100644 --- a/wings/slardar/src/main/java/pro/fessional/wings/slardar/spring/bean/SlardarEventConfiguration.java +++ b/wings/slardar/src/main/java/pro/fessional/wings/slardar/spring/bean/SlardarEventConfiguration.java @@ -6,7 +6,7 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.task.TaskExecutionProperties; -import org.springframework.boot.task.TaskExecutorBuilder; +import org.springframework.boot.task.ThreadPoolTaskExecutorBuilder; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -38,7 +38,7 @@ public class SlardarEventConfiguration { @Bean(name = slardarEventExecutor) @ConditionalWingsEnabled public Executor slardarEventExecutor(SlardarAsyncProp prop) { - TaskExecutorBuilder builder = new TaskExecutorBuilder(); + ThreadPoolTaskExecutorBuilder builder = new ThreadPoolTaskExecutorBuilder(); final TaskExecutionProperties event = prop.getEvent(); final TaskExecutionProperties.Pool pool = event.getPool(); builder = builder.queueCapacity(pool.getQueueCapacity()); diff --git a/wings/warlock-bond/src/main/java/pro/fessional/wings/warlock/service/perm/impl/WarlockPermServiceImpl.java b/wings/warlock-bond/src/main/java/pro/fessional/wings/warlock/service/perm/impl/WarlockPermServiceImpl.java index b6406bf9..4219985c 100644 --- a/wings/warlock-bond/src/main/java/pro/fessional/wings/warlock/service/perm/impl/WarlockPermServiceImpl.java +++ b/wings/warlock-bond/src/main/java/pro/fessional/wings/warlock/service/perm/impl/WarlockPermServiceImpl.java @@ -153,11 +153,7 @@ public void modify(long permId, @NotNull String remark) { }); if (rct > 0) { - wingsTableCudHandler.handle(this.getClass(), Cud.Update, t, () -> { - Map> field = new HashMap<>(); - field.put(t.Id.getName(), List.of(permId)); - return field; - }); + wingsTableCudHandler.handle(this.getClass(), Cud.Update, t, field -> field.put(t.Id.getName(), List.of(permId))); } } } diff --git a/wings/warlock-bond/src/main/java/pro/fessional/wings/warlock/service/perm/impl/WarlockRoleServiceImpl.java b/wings/warlock-bond/src/main/java/pro/fessional/wings/warlock/service/perm/impl/WarlockRoleServiceImpl.java index 05c39e11..626c2553 100644 --- a/wings/warlock-bond/src/main/java/pro/fessional/wings/warlock/service/perm/impl/WarlockRoleServiceImpl.java +++ b/wings/warlock-bond/src/main/java/pro/fessional/wings/warlock/service/perm/impl/WarlockRoleServiceImpl.java @@ -165,11 +165,7 @@ public void modify(long roleId, String remark) { }); if (rct > 0) { - wingsTableCudHandler.handle(this.getClass(), Cud.Update, t, () -> { - Map> field = new HashMap<>(); - field.put(t.Id.getName(), List.of(roleId)); - return field; - }); + wingsTableCudHandler.handle(this.getClass(), Cud.Update, t, field -> field.put(t.Id.getName(), List.of(roleId))); } } } diff --git a/wings/warlock-shadow/src/main/java/pro/fessional/wings/warlock/security/handler/AccessFailureHandler.java b/wings/warlock-shadow/src/main/java/pro/fessional/wings/warlock/security/handler/AccessFailureHandler.java index 4e69a093..e1a97a87 100644 --- a/wings/warlock-shadow/src/main/java/pro/fessional/wings/warlock/security/handler/AccessFailureHandler.java +++ b/wings/warlock-shadow/src/main/java/pro/fessional/wings/warlock/security/handler/AccessFailureHandler.java @@ -1,7 +1,6 @@ package pro.fessional.wings.warlock.security.handler; import com.fasterxml.jackson.databind.ObjectMapper; -import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import lombok.Setter; @@ -35,7 +34,7 @@ public class AccessFailureHandler implements AccessDeniedHandler { protected MessageSource messageSource; @Override - public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException { + public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException { log.debug("handled accessDeniedException", accessDeniedException); response.setStatus(HttpStatus.FORBIDDEN.value()); response.setContentType(APPLICATION_JSON_VALUE); diff --git a/wings/warlock-shadow/src/main/java/pro/fessional/wings/warlock/security/session/NonceTokenSessionHelper.java b/wings/warlock-shadow/src/main/java/pro/fessional/wings/warlock/security/session/NonceTokenSessionHelper.java index e8f660c6..27179478 100644 --- a/wings/warlock-shadow/src/main/java/pro/fessional/wings/warlock/security/session/NonceTokenSessionHelper.java +++ b/wings/warlock-shadow/src/main/java/pro/fessional/wings/warlock/security/session/NonceTokenSessionHelper.java @@ -2,13 +2,10 @@ import org.cache2k.Cache; -import org.cache2k.Cache2kBuilder; import org.jetbrains.annotations.Nullable; import pro.fessional.mirana.data.R; import pro.fessional.wings.slardar.cache.cache2k.WingsCache2k; -import java.util.concurrent.TimeUnit; - /** *
diff --git a/wings/warlock-shadow/src/main/java/pro/fessional/wings/warlock/spring/bean/WarlockSecurityConfConfiguration.java b/wings/warlock-shadow/src/main/java/pro/fessional/wings/warlock/spring/bean/WarlockSecurityConfConfiguration.java
index 17eaa3b6..32f53be4 100644
--- a/wings/warlock-shadow/src/main/java/pro/fessional/wings/warlock/spring/bean/WarlockSecurityConfConfiguration.java
+++ b/wings/warlock-shadow/src/main/java/pro/fessional/wings/warlock/spring/bean/WarlockSecurityConfConfiguration.java
@@ -10,6 +10,8 @@
 import org.springframework.core.annotation.Order;
 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
 import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
+import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
+import org.springframework.security.config.annotation.web.configurers.RequestCacheConfigurer;
 import org.springframework.security.core.session.SessionRegistry;
 import org.springframework.security.web.SecurityFilterChain;
 import org.springframework.security.web.access.AccessDeniedHandler;
@@ -29,6 +31,7 @@
 import pro.fessional.wings.slardar.security.WingsAuthDetailsSource;
 import pro.fessional.wings.slardar.servlet.request.FakeHttpServletRequest;
 import pro.fessional.wings.slardar.servlet.response.ResponseHelper;
+import pro.fessional.wings.slardar.spring.conf.WingsBindLoginConfigurer;
 import pro.fessional.wings.slardar.spring.help.SecurityConfigHelper;
 import pro.fessional.wings.slardar.spring.help.SecurityConfigHelper.MatcherHelper;
 import pro.fessional.wings.warlock.spring.conf.HttpSecurityCustomizer;
@@ -100,8 +103,7 @@ public HttpSecurityCustomizer warlockSecurityBindHttpConfigure(
             final LogoutSuccessHandler logoutOkHandler = logoutSuccessHandler.getIfAvailable();
             log.info("WarlockShadow conf HttpSecurity, authenticationDetailsSource=" + (authDetailSource == null ? "null" : authDetailSource.getClass()));
 
-            http.apply(SecurityConfigHelper.http())
-                .bindLogin(conf -> {
+            http.with(new WingsBindLoginConfigurer(), conf -> {
                             conf.loginPage(securityProp.getLoginPage()) // init authenticationEntryPoint, 401 page
                                 // init filter.RequestMatcher
                                 .loginProcessingUrl(securityProp.getLoginProcUrl(), securityProp.getLoginProcMethod()) // by filter,no controller
@@ -122,7 +124,6 @@ public HttpSecurityCustomizer warlockSecurityBindHttpConfigure(
                             }
                         }
                 )
-                .and()
                 .logout(conf -> {
                             conf.logoutUrl(securityProp.getLogoutUrl())
                                 .clearAuthentication(true)
@@ -152,7 +153,7 @@ public HttpSecurityCustomizer warlockSecurityBindHttpConfigure(
             final AccessDeniedHandler deniedHandler = accessDeniedHandler.getIfAvailable();
             if (deniedHandler != null) {
                 log.info("WarlockShadow conf exceptionHandling, accessDeniedHandler=" + deniedHandler.getClass());
-                http.exceptionHandling().accessDeniedHandler(deniedHandler);
+                http.exceptionHandling(c -> c.accessDeniedHandler(deniedHandler));
             }
         };
     }
@@ -163,8 +164,7 @@ public HttpSecurityCustomizer warlockSecurityBindHttpConfigure(
     public HttpSecurityCustomizer warlockSecurityAuthHttpConfigure(WarlockSecurityProp securityProp) {
         log.info("WarlockShadow spring-bean warlockSecurityAuthHttpConfigure");
 
-        return http -> {
-            final var conf = http.authorizeHttpRequests();
+        return http -> http.authorizeHttpRequests(conf -> {
             // 1 PermitAll
             final Set permed = CommonPropHelper.onlyValue(securityProp.getPermitAll().values());
             if (!permed.isEmpty()) {
@@ -200,7 +200,7 @@ public HttpSecurityCustomizer warlockSecurityAuthHttpConfigure(WarlockSecurityPr
                     conf.requestMatchers(url).hasAnyAuthority(pms.toArray(Null.StrArr));
                 }
             }
-        };
+        });
     }
 
     @Bean
@@ -208,7 +208,7 @@ public HttpSecurityCustomizer warlockSecurityAuthHttpConfigure(WarlockSecurityPr
     @Order(WingsOrdered.Lv4Application + 100)
     public HttpSecurityCustomizer warlockSecurityHttpBaseConfigure() {
         log.info("WarlockShadow spring-bean warlockSecurityHttpBaseConfigure");
-        return HttpSecurity::httpBasic;
+        return http -> http.httpBasic(c -> {});
     }
 
     @Bean
@@ -220,27 +220,27 @@ public HttpSecurityCustomizer warlockSecurityAutoHttpConfigure(
         log.info("WarlockShadow spring-bean warlockSecurityAutoHttpConfigure");
         return http -> {
             // cors
-            http.cors().configurationSource(SecurityConfigHelper.corsPermitAll());
+            http.cors(c -> c.configurationSource(SecurityConfigHelper.corsPermitAll()));
 
             // cache
             final RequestCache rc = cache.getIfAvailable();
             if (rc == null) {
-                http.requestCache().disable();
+                http.requestCache(RequestCacheConfigurer::disable);
                 log.info("WarlockShadow conf HttpSecurity, requestCache disable");
             }
             else {
-                http.requestCache().requestCache(rc);
+                http.requestCache(c -> c.requestCache(rc));
                 log.info("WarlockShadow conf HttpSecurity, requestCache " + rc.getClass().getName());
             }
 
             // csrf
             final CsrfTokenRepository ct = csrf.getIfAvailable();
             if (ct == null) {
-                http.csrf().disable();
+                http.csrf(AbstractHttpConfigurer::disable);
                 log.info("WarlockShadow conf HttpSecurity, csrf disable");
             }
             else {
-                http.csrf().csrfTokenRepository(ct);
+                http.csrf(c -> c.csrfTokenRepository(ct));
                 log.info("WarlockShadow conf HttpSecurity, csrf " + ct.getClass().getName());
             }
         };
@@ -277,19 +277,19 @@ public SecurityFilterChain securityFilterChain(WarlockSecurityProp securityProp,
             log.info("WarlockShadow conf securityFilterChain, anyRequest=" + anyRequest);
             String str = anyRequest.trim();
             if (!StringUtils.hasText(str) || "permitAll".equalsIgnoreCase(str)) {
-                http.authorizeHttpRequests().anyRequest().permitAll();
+                http.authorizeHttpRequests(c -> c.anyRequest().permitAll());
             }
             else if ("authenticated".equalsIgnoreCase(str)) {
-                http.authorizeHttpRequests().anyRequest().authenticated();
+                http.authorizeHttpRequests(c -> c.anyRequest().authenticated());
             }
             else if ("anonymous".equalsIgnoreCase(str)) {
-                http.authorizeHttpRequests().anyRequest().anonymous();
+                http.authorizeHttpRequests(c -> c.anyRequest().anonymous());
             }
             else if ("fullyAuthenticated".equalsIgnoreCase(str)) {
-                http.authorizeHttpRequests().anyRequest().fullyAuthenticated();
+                http.authorizeHttpRequests(c -> c.anyRequest().fullyAuthenticated());
             }
             else {
-                http.authorizeHttpRequests().anyRequest().hasAnyAuthority(str.split("[, \t\r\n]+"));
+                http.authorizeHttpRequests(c -> c.anyRequest().hasAnyAuthority(str.split("[, \t\r\n]+")));
             }
         }
         log.info("WarlockShadow conf securityFilterChain, done");
diff --git a/wings/warlock/src/main/java/pro/fessional/wings/warlock/spring/prop/WarlockEnabledProp.java b/wings/warlock/src/main/java/pro/fessional/wings/warlock/spring/prop/WarlockEnabledProp.java
index 8d18a90b..09fd6cf2 100644
--- a/wings/warlock/src/main/java/pro/fessional/wings/warlock/spring/prop/WarlockEnabledProp.java
+++ b/wings/warlock/src/main/java/pro/fessional/wings/warlock/spring/prop/WarlockEnabledProp.java
@@ -35,7 +35,7 @@ public class WarlockEnabledProp {
     public static final String Key$secCheckUrl = Key + ".sec-check-url";
 
     /**
-     * whether to enable Web auto config, eg. firewall, debug, etc.
+     * whether to enable Web auto config, e.g. firewall, debug, etc.
      *
      * @see #Key$secWebAuto
      */

From dda35dc4f751c533bc2c8364cac83cb16cddba04 Mon Sep 17 00:00:00 2001
From: trydofor 
Date: Thu, 15 Feb 2024 09:15:45 +0800
Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=9A=A8=20inspect:slf4j,exception,Rand?=
 =?UTF-8?q?omUtils=20#184?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../wings/tiny/mail/sender/MailSenderManager.java          | 7 ++-----
 .../tiny/task/service/impl/TinyTaskExecServiceImpl.java    | 7 ++-----
 .../wings/faceless/codegen/ConstantEnumGenerator.java      | 6 ++----
 .../wings/faceless/jooqgen/WingsCodeGenerator.java         | 6 ++----
 .../wings/faceless/util/FlywaveRevisionScanner.java        | 6 ++----
 .../wings/slardar/app/conf/TestSecurityConfiguration.java  | 6 ++++--
 .../slardar/security/impl/AbstractAuthPermCheckCombo.java  | 2 +-
 .../wings/slardar/servlet/response/view/DownloadView.java  | 3 ++-
 .../slardar/servlet/response/view/InputStreamView.java     | 3 ++-
 .../wings/slardar/servlet/response/view/OnlyView.java      | 5 +++--
 .../wings/slardar/servlet/response/view/PlainTextView.java | 3 ++-
 .../slardar/security/pass/DefaultPasssaltEncoderTest.java  | 2 +-
 .../testing/faceless/database/TestingDatabaseHelper.java   | 6 ++----
 .../slardar/security/handler/TestingLoginHandler.java      | 6 ++----
 .../warlock/controller/api/AbstractApiAuthController.java  | 7 ++++---
 15 files changed, 33 insertions(+), 42 deletions(-)

diff --git a/radiant/tiny-mail/src/main/java/pro/fessional/wings/tiny/mail/sender/MailSenderManager.java b/radiant/tiny-mail/src/main/java/pro/fessional/wings/tiny/mail/sender/MailSenderManager.java
index 66b89cf6..4349474b 100644
--- a/radiant/tiny-mail/src/main/java/pro/fessional/wings/tiny/mail/sender/MailSenderManager.java
+++ b/radiant/tiny-mail/src/main/java/pro/fessional/wings/tiny/mail/sender/MailSenderManager.java
@@ -6,7 +6,6 @@
 import lombok.RequiredArgsConstructor;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.RandomUtils;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.springframework.boot.autoconfigure.mail.MailProperties;
@@ -107,8 +106,7 @@ public void singleSend(@NotNull TinyMailMessage message, long maxWait, @Nullable
         final MimeMessage mimeMessage = prepareMimeMessage(message, preparer, sender);
 
         if (isDryrun(message)) {
-            final int slp = RandomUtils.nextInt(10, 2000);
-            Sleep.ignoreInterrupt(slp);
+            final long slp = Sleep.ignoreInterrupt(10, 2000);
             log.info("single mail dryrun and sleep {} ms", slp);
             return;
         }
@@ -186,8 +184,7 @@ public List batchSend(Collection message
         }
 
         if (dryrunCount > 0) {
-            final int slp = RandomUtils.nextInt(10, 2000);
-            Sleep.ignoreInterrupt(slp);
+            final long slp = Sleep.ignoreInterrupt(10, 2000);
             log.info("batch mail dryrun and sleep {} ms", slp);
             final long avg = slp / dryrunCount;
             for (BatchResult rst : results) {
diff --git a/radiant/tiny-task/src/main/java/pro/fessional/wings/tiny/task/service/impl/TinyTaskExecServiceImpl.java b/radiant/tiny-task/src/main/java/pro/fessional/wings/tiny/task/service/impl/TinyTaskExecServiceImpl.java
index 05a68c15..0cbc7eca 100644
--- a/radiant/tiny-task/src/main/java/pro/fessional/wings/tiny/task/service/impl/TinyTaskExecServiceImpl.java
+++ b/radiant/tiny-task/src/main/java/pro/fessional/wings/tiny/task/service/impl/TinyTaskExecServiceImpl.java
@@ -2,7 +2,6 @@
 
 import lombok.Setter;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.RandomUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.jooq.Field;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -129,9 +128,8 @@ public boolean force(long id) {
 
                 final Object result;
                 if (execProp.isDryrun()) {
-                    final int slp = RandomUtils.nextInt(10, 2000);
+                    final long slp = Sleep.ignoreInterrupt(10, 2000);
                     result = "dryrun and sleep " + slp;
-                    Sleep.ignoreInterrupt(slp);
                     log.info("task force done, dryrun and sleep {} ms, id={}", slp, id);
                 }
                 else {
@@ -257,9 +255,8 @@ private boolean relaunch(long id) {
 
                     final Object result;
                     if (execProp.isDryrun()) {
-                        final int slp = RandomUtils.nextInt(10, 2000);
+                        final long slp = Sleep.ignoreInterrupt(10, 2000);
                         result = "dryrun and sleep " + slp;
-                        Sleep.ignoreInterrupt(slp);
                         log.info("task done, dryrun and sleep {} ms, id={}", slp, id);
                     }
                     else {
diff --git a/wings/faceless-codegen/src/main/java/pro/fessional/wings/faceless/codegen/ConstantEnumGenerator.java b/wings/faceless-codegen/src/main/java/pro/fessional/wings/faceless/codegen/ConstantEnumGenerator.java
index d086c40c..fbb1f1cb 100644
--- a/wings/faceless-codegen/src/main/java/pro/fessional/wings/faceless/codegen/ConstantEnumGenerator.java
+++ b/wings/faceless-codegen/src/main/java/pro/fessional/wings/faceless/codegen/ConstantEnumGenerator.java
@@ -3,10 +3,9 @@
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.jetbrains.annotations.Contract;
 import org.jetbrains.annotations.NotNull;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import pro.fessional.meepo.Meepo;
 import pro.fessional.mirana.io.InputStreams;
 import pro.fessional.mirana.pain.IORuntimeException;
@@ -35,10 +34,9 @@
  * @author trydofor
  * @since 2019-09-24
  */
+@Slf4j
 public class ConstantEnumGenerator {
 
-    private static final Logger log = LoggerFactory.getLogger(ConstantEnumGenerator.class);
-
     /**
      * Replacement for non-java characters, empty means ignore
      */
diff --git a/wings/faceless-codegen/src/main/java/pro/fessional/wings/faceless/jooqgen/WingsCodeGenerator.java b/wings/faceless-codegen/src/main/java/pro/fessional/wings/faceless/jooqgen/WingsCodeGenerator.java
index eb893a56..64958e0d 100644
--- a/wings/faceless-codegen/src/main/java/pro/fessional/wings/faceless/jooqgen/WingsCodeGenerator.java
+++ b/wings/faceless-codegen/src/main/java/pro/fessional/wings/faceless/jooqgen/WingsCodeGenerator.java
@@ -1,5 +1,6 @@
 package pro.fessional.wings.faceless.jooqgen;
 
+import lombok.extern.slf4j.Slf4j;
 import org.jetbrains.annotations.Contract;
 import org.jetbrains.annotations.NotNull;
 import org.jooq.Converter;
@@ -14,8 +15,6 @@
 import org.jooq.meta.jaxb.Logging;
 import org.jooq.meta.jaxb.Strategy;
 import org.jooq.meta.jaxb.Target;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.util.StringUtils;
 import pro.fessional.mirana.data.CodeEnum;
 import pro.fessional.mirana.data.Null;
@@ -52,10 +51,9 @@
  * @author trydofor
  * @since 2019-05-31
  */
+@Slf4j
 public class WingsCodeGenerator {
 
-    private static final Logger log = LoggerFactory.getLogger(WingsCodeGenerator.class);
-
     /**
      * Generate Jooq Code
      *
diff --git a/wings/faceless-flywave/src/main/java/pro/fessional/wings/faceless/util/FlywaveRevisionScanner.java b/wings/faceless-flywave/src/main/java/pro/fessional/wings/faceless/util/FlywaveRevisionScanner.java
index b5227be7..ddf95ada 100644
--- a/wings/faceless-flywave/src/main/java/pro/fessional/wings/faceless/util/FlywaveRevisionScanner.java
+++ b/wings/faceless-flywave/src/main/java/pro/fessional/wings/faceless/util/FlywaveRevisionScanner.java
@@ -1,9 +1,8 @@
 package pro.fessional.wings.faceless.util;
 
+import lombok.extern.slf4j.Slf4j;
 import org.jetbrains.annotations.Contract;
 import org.jetbrains.annotations.NotNull;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.core.io.Resource;
 import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
 import org.springframework.util.StreamUtils;
@@ -35,10 +34,9 @@
  * @author trydofor
  * @since 2019-06-14
  */
+@Slf4j
 public class FlywaveRevisionScanner {
 
-    private static final Logger log = LoggerFactory.getLogger(FlywaveRevisionScanner.class);
-
     public static final String REVISION_PATH_REVIFILE_EXTN = ".sql";
     public static final String REVISION_PATH_REVIFILE_TAIL = "**/*" + REVISION_PATH_REVIFILE_EXTN;
     public static final String REVISION_PATH_FLYWAVE_HEAD = "classpath*:/wings-flywave/";
diff --git a/wings/slardar-hazel-session/src/test/java/pro/fessional/wings/slardar/app/conf/TestSecurityConfiguration.java b/wings/slardar-hazel-session/src/test/java/pro/fessional/wings/slardar/app/conf/TestSecurityConfiguration.java
index e155bd76..dbc81cf4 100644
--- a/wings/slardar-hazel-session/src/test/java/pro/fessional/wings/slardar/app/conf/TestSecurityConfiguration.java
+++ b/wings/slardar-hazel-session/src/test/java/pro/fessional/wings/slardar/app/conf/TestSecurityConfiguration.java
@@ -7,6 +7,8 @@
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
+import org.springframework.security.config.annotation.web.configurers.RequestCacheConfigurer;
 import org.springframework.security.core.session.SessionRegistry;
 import org.springframework.security.web.SecurityFilterChain;
 import pro.fessional.wings.testing.slardar.security.handler.TestingLoginHandler;
@@ -74,8 +76,8 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
 //            .exceptionHandling(conf -> conf
 //                    .accessDeniedHandler()
 //            )
-            .requestCache().disable()
-            .csrf().disable();
+            .requestCache(RequestCacheConfigurer::disable)
+            .csrf(AbstractHttpConfigurer::disable);
         return http.build();
     }
 }
diff --git a/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/security/impl/AbstractAuthPermCheckCombo.java b/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/security/impl/AbstractAuthPermCheckCombo.java
index 949b79ec..a15d5a8e 100644
--- a/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/security/impl/AbstractAuthPermCheckCombo.java
+++ b/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/security/impl/AbstractAuthPermCheckCombo.java
@@ -19,7 +19,7 @@
 
 public abstract class AbstractAuthPermCheckCombo implements ComboWingsAuthCheckService.Combo {
 
-    private final Logger log = LoggerFactory.getLogger(this.getClass());
+    protected final Logger log = LoggerFactory.getLogger(this.getClass());
 
     @Override
     public boolean check(WingsUserDetails userDetails, WingsBindAuthToken authentication) {
diff --git a/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/servlet/response/view/DownloadView.java b/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/servlet/response/view/DownloadView.java
index 99cabd07..a9b2e907 100644
--- a/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/servlet/response/view/DownloadView.java
+++ b/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/servlet/response/view/DownloadView.java
@@ -5,6 +5,7 @@
 import org.jetbrains.annotations.NotNull;
 import pro.fessional.wings.slardar.servlet.response.ResponseHelper;
 
+import java.io.IOException;
 import java.io.InputStream;
 
 import static pro.fessional.wings.slardar.servlet.response.ResponseHelper.getDownloadContentType;
@@ -23,7 +24,7 @@ public DownloadView(InputStream data, String fileName) {
     }
 
     @Override
-    public void responseData(@NotNull InputStream data, @NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws Exception {
+    public void responseData(@NotNull InputStream data, @NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws IOException {
         ResponseHelper.setDownloadContentDisposition(response, fileName);
         super.responseData(data, request, response);
     }
diff --git a/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/servlet/response/view/InputStreamView.java b/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/servlet/response/view/InputStreamView.java
index 28a3bb6d..392590f4 100644
--- a/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/servlet/response/view/InputStreamView.java
+++ b/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/servlet/response/view/InputStreamView.java
@@ -5,6 +5,7 @@
 import org.apache.commons.io.IOUtils;
 import org.jetbrains.annotations.NotNull;
 
+import java.io.IOException;
 import java.io.InputStream;
 
 /**
@@ -18,7 +19,7 @@ public InputStreamView(String contentType, InputStream data) {
     }
 
     @Override
-    public void responseData(@NotNull InputStream data, @NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws Exception {
+    public void responseData(@NotNull InputStream data, @NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws IOException {
         IOUtils.copy(data, response.getOutputStream(), 1024);
         IOUtils.closeQuietly(data, null);
     }
diff --git a/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/servlet/response/view/OnlyView.java b/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/servlet/response/view/OnlyView.java
index 728e6590..ddcdf2d0 100644
--- a/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/servlet/response/view/OnlyView.java
+++ b/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/servlet/response/view/OnlyView.java
@@ -6,6 +6,7 @@
 import org.jetbrains.annotations.NotNull;
 import org.springframework.web.servlet.view.AbstractView;
 
+import java.io.IOException;
 import java.util.Map;
 
 /**
@@ -24,12 +25,12 @@ public OnlyView(String contentType, T data) {
         this.data = data;
     }
 
-    public abstract void responseData(@NotNull T data, @NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws Exception;
+    public abstract void responseData(@NotNull T data, @NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws IOException;
 
     @Override
     protected void renderMergedOutputModel(@NotNull Map model,
                                            @NotNull HttpServletRequest request,
-                                           HttpServletResponse response) throws Exception {
+                                           HttpServletResponse response) throws IOException {
         response.setContentType(this.contentType);
         if (data != null) {
             responseData(data, request, response);
diff --git a/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/servlet/response/view/PlainTextView.java b/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/servlet/response/view/PlainTextView.java
index 0aeee37b..e26e6fee 100644
--- a/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/servlet/response/view/PlainTextView.java
+++ b/wings/slardar-webmvc/src/main/java/pro/fessional/wings/slardar/servlet/response/view/PlainTextView.java
@@ -4,6 +4,7 @@
 import jakarta.servlet.http.HttpServletResponse;
 import org.jetbrains.annotations.NotNull;
 
+import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 
 /**
@@ -17,7 +18,7 @@ public PlainTextView(String contentType, String data) {
     }
 
     @Override
-    public void responseData(@NotNull String data, @NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws Exception {
+    public void responseData(@NotNull String data, @NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws IOException {
         response.getOutputStream().write(data.getBytes(StandardCharsets.UTF_8));
     }
 }
diff --git a/wings/slardar-webmvc/src/test/java/pro/fessional/wings/slardar/security/pass/DefaultPasssaltEncoderTest.java b/wings/slardar-webmvc/src/test/java/pro/fessional/wings/slardar/security/pass/DefaultPasssaltEncoderTest.java
index db36f589..dcb4f081 100644
--- a/wings/slardar-webmvc/src/test/java/pro/fessional/wings/slardar/security/pass/DefaultPasssaltEncoderTest.java
+++ b/wings/slardar-webmvc/src/test/java/pro/fessional/wings/slardar/security/pass/DefaultPasssaltEncoderTest.java
@@ -19,7 +19,7 @@
  * @author trydofor
  * @since 2021-02-25
  */
-@SuppressWarnings("ALL")
+@SuppressWarnings("all")
 @Slf4j
 class DefaultPasssaltEncoderTest {
     private final PasswordEncoder bcrypt = new BCryptPasswordEncoder();
diff --git a/wings/testing-faceless/src/main/java/pro/fessional/wings/testing/faceless/database/TestingDatabaseHelper.java b/wings/testing-faceless/src/main/java/pro/fessional/wings/testing/faceless/database/TestingDatabaseHelper.java
index b3b0f790..940c1ce1 100644
--- a/wings/testing-faceless/src/main/java/pro/fessional/wings/testing/faceless/database/TestingDatabaseHelper.java
+++ b/wings/testing-faceless/src/main/java/pro/fessional/wings/testing/faceless/database/TestingDatabaseHelper.java
@@ -1,8 +1,7 @@
 package pro.fessional.wings.testing.faceless.database;
 
+import lombok.extern.slf4j.Slf4j;
 import org.junit.jupiter.api.Assertions;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.jdbc.core.JdbcTemplate;
 import pro.fessional.mirana.data.Diff;
 import pro.fessional.mirana.io.InputStreams;
@@ -22,10 +21,9 @@
  * @author trydofor
  * @since 2020-05-22
  */
+@Slf4j
 public class TestingDatabaseHelper {
 
-    private static final Logger log = LoggerFactory.getLogger(TestingDatabaseHelper.class);
-
     private final DataSourceContext dataSourceContext;
 
     private final boolean hasH2;
diff --git a/wings/testing-slardar/src/main/java/pro/fessional/wings/testing/slardar/security/handler/TestingLoginHandler.java b/wings/testing-slardar/src/main/java/pro/fessional/wings/testing/slardar/security/handler/TestingLoginHandler.java
index 49948651..a67f341e 100644
--- a/wings/testing-slardar/src/main/java/pro/fessional/wings/testing/slardar/security/handler/TestingLoginHandler.java
+++ b/wings/testing-slardar/src/main/java/pro/fessional/wings/testing/slardar/security/handler/TestingLoginHandler.java
@@ -1,8 +1,7 @@
 package pro.fessional.wings.testing.slardar.security.handler;
 
 import lombok.Setter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.i18n.TimeZoneAwareLocaleContext;
 import org.springframework.security.web.authentication.AuthenticationFailureHandler;
@@ -18,10 +17,9 @@
  * @since 2021-02-01
  */
 @SuppressWarnings({"UastIncorrectHttpHeaderInspection", "CanBeFinal"})
+@Slf4j
 public class TestingLoginHandler {
 
-    private static final Logger log = LoggerFactory.getLogger(TestingLoginHandler.class);
-
     @Setter(onMethod_ = {@Autowired})
     private WingsLocaleResolver wingsLocaleResolver;
 
diff --git a/wings/warlock-shadow/src/main/java/pro/fessional/wings/warlock/controller/api/AbstractApiAuthController.java b/wings/warlock-shadow/src/main/java/pro/fessional/wings/warlock/controller/api/AbstractApiAuthController.java
index 8d84ceb3..670d86a6 100644
--- a/wings/warlock-shadow/src/main/java/pro/fessional/wings/warlock/controller/api/AbstractApiAuthController.java
+++ b/wings/warlock-shadow/src/main/java/pro/fessional/wings/warlock/controller/api/AbstractApiAuthController.java
@@ -30,6 +30,7 @@
 import pro.fessional.wings.warlock.service.auth.WarlockTicketService.Term;
 import pro.fessional.wings.warlock.spring.prop.WarlockApiAuthProp;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintWriter;
 import java.util.Collection;
@@ -52,12 +53,12 @@
  */
 public abstract class AbstractApiAuthController {
 
+    protected final Logger log = org.slf4j.LoggerFactory.getLogger(this.getClass());
+
     public static final int MD5_LEN = MdHelp.LEN_MD5_HEX;
     public static final int SHA1_LEN = MdHelp.LEN_SHA1_HEX;
     public static final int HMAC_LEN = 64;
 
-    protected final Logger log = org.slf4j.LoggerFactory.getLogger(this.getClass());
-
     /**
      * Whether it is compatible mode (send clientId directly), or only the ticket mode.
      */
@@ -404,7 +405,7 @@ else if (len == HMAC_LEN) {
      * `true` means it has been processed and can response,
      * `false` means it has not been processed.
      */
-    public abstract boolean handle(@NotNull HttpServletRequest request, @NotNull ApiEntity entity) throws Exception;
+    public abstract boolean handle(@NotNull HttpServletRequest request, @NotNull ApiEntity entity) throws IOException;
 
     public enum ApiError {
         SignatureMissing,

From 165811f6ef2afbf6a0d10727a97709e951a80941 Mon Sep 17 00:00:00 2001
From: trydofor 
Date: Thu, 15 Feb 2024 12:28:53 +0800
Subject: [PATCH 4/5] =?UTF-8?q?=E2=9C=85=20fix=20naming=20and=20coverage?=
 =?UTF-8?q?=20#203?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .github/workflows/release.yml    |  4 ++--
 observe/scripts/wings-testing.sh |  6 ++++--
 pom.xml                          | 14 ++++++++++----
 radiant/devs-coverage/pom.xml    | 10 ----------
 wings/testing-batrider/pom.xml   |  2 +-
 wings/testing-docker/pom.xml     |  2 +-
 wings/testing-faceless/pom.xml   |  2 +-
 wings/testing-silencer/pom.xml   |  2 +-
 wings/testing-slardar/pom.xml    |  2 +-
 wings/testing-warlock/pom.xml    |  2 +-
 10 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 993893e7..209711c8 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -145,8 +145,8 @@ jobs:
           mvn -P '!example,!devs' -Dmaven.test.skip=true clean install
           mvn -pl ':devs-codegen' -Ddevs-initdb=true clean test
           mvn -P 'coverage,!example,!devs' -Dmaven.test.failure.ignore=$TESTFAILS_IGNORE test
-          mvn -pl ':devs-coverage' -am jacoco:report-aggregate
-          mvn -pl ':devs-coverage' -DrepoToken=$COVERALLS_WINGS -DdryRun=$COVERALLS_DRYRUN verify
+          mvn -P 'coverage' -pl ':devs-coverage' -am jacoco:report-aggregate
+          mvn -pl ':devs-coverage' -DrepoToken=$COVERALLS_WINGS -DdryRun=$COVERALLS_DRYRUN -Dwings.rootdir=../.. coveralls:report
         env:
           TZ: Asia/Shanghai
           JAVA_HOME: ${{ steps.settings.outputs.JAVA_HOME }}
diff --git a/observe/scripts/wings-testing.sh b/observe/scripts/wings-testing.sh
index baf5eeba..46714042 100644
--- a/observe/scripts/wings-testing.sh
+++ b/observe/scripts/wings-testing.sh
@@ -67,8 +67,10 @@ if [[ "$_ans" != "" ]]; then
     _step="$_ans"
 fi
 # ##############
+TZ=Asia/Shanghai
 echo "====================="
 pwd
+echo "TZ=$TZ"
 echo "MAVEN_OPTS=$MAVEN_OPTS"
 echo "LOG_LEVEL=$LOG_LEVEL"
 echo "TEST_VERBOSE=$TEST_VERBOSE"
@@ -80,6 +82,6 @@ set -x
 [[ "$_step" -le "1" ]] && mvn -P '!example,!devs' -Dmaven.test.skip=true clean install
 [[ "$_step" -le "2" ]] && mvn -pl ':devs-codegen' -Ddevs-initdb=true clean test
 [[ "$_step" -le "3" ]] && mvn -P 'coverage,!example,!devs' test
-[[ "$_step" -le "4" ]] && mvn -pl ':devs-coverage' -am jacoco:report-aggregate
-[[ "$_step" -le "5" ]] && mvn -pl ':devs-coverage' -DrepoToken=$COVERALLS_WINGS -DdryRun=$COVERALLS_DRYRUN verify
+[[ "$_step" -le "4" ]] && mvn -P 'coverage' -pl ':devs-coverage' -am jacoco:report-aggregate
+[[ "$_step" -le "5" ]] && mvn -pl ':devs-coverage' -DrepoToken=$COVERALLS_WINGS -DdryRun=$COVERALLS_DRYRUN -Dwings.rootdir=../.. coveralls:report
 
diff --git a/pom.xml b/pom.xml
index c340d224..8d28b83b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -694,6 +694,13 @@
                                 prepare-agent
                             
                         
+                        
+                            post-unit-test
+                            test
+                            
+                                report
+                            
+                        
                     
                 
                 
@@ -1003,6 +1010,9 @@
                         jacoco-maven-plugin
                         
                             
+                                **/database/autogen/**
+                                **/enums/autogen/**
+                                **/security/autogen/**
                                 **/*Const.*
                                 **/*Const$*
                                 **/*Attribute.*
@@ -1018,10 +1028,6 @@
                             
                         
                     
-                    
-                        org.eluder.coveralls
-                        coveralls-maven-plugin
-                    
                 
             
         
diff --git a/radiant/devs-coverage/pom.xml b/radiant/devs-coverage/pom.xml
index 8d09eeab..f5bdf284 100644
--- a/radiant/devs-coverage/pom.xml
+++ b/radiant/devs-coverage/pom.xml
@@ -100,7 +100,6 @@
                 org.eluder.coveralls
                 coveralls-maven-plugin
                 
-                    ${wings.rootdir}
                     
                         /jacoco
                         /jacoco-aggregate
@@ -147,15 +146,6 @@
                         ${wings.rootdir}/radiant/tiny-task/target/generated-sources/annotations
                     
                 
-                
-                    
-                        jacoco-coverage
-                        verify
-                        
-                            report
-                        
-                    
-                
             
         
     
diff --git a/wings/testing-batrider/pom.xml b/wings/testing-batrider/pom.xml
index 8844a05a..bb482b9f 100644
--- a/wings/testing-batrider/pom.xml
+++ b/wings/testing-batrider/pom.xml
@@ -13,7 +13,7 @@
     testing-batrider
     jar
 
-    Wings::Batrider::Test
+    Wings::Testing::Batrider
     Testing of Servicecomb
 
     
diff --git a/wings/testing-docker/pom.xml b/wings/testing-docker/pom.xml
index c57feb68..00996256 100644
--- a/wings/testing-docker/pom.xml
+++ b/wings/testing-docker/pom.xml
@@ -13,7 +13,7 @@
     testing-docker
     jar
 
-    Wings::Testing:Docker
+    Wings::Testing::Docker
     Docker(MySql/H2) for testing
 
     
diff --git a/wings/testing-faceless/pom.xml b/wings/testing-faceless/pom.xml
index 8484270e..59a1ece6 100644
--- a/wings/testing-faceless/pom.xml
+++ b/wings/testing-faceless/pom.xml
@@ -13,7 +13,7 @@
     testing-faceless
     jar
 
-    Wings::Faceless::Test
+    Wings::Testing::Faceless
     Testing of Faceless
 
     
diff --git a/wings/testing-silencer/pom.xml b/wings/testing-silencer/pom.xml
index 6e5161f2..c9b5fff3 100644
--- a/wings/testing-silencer/pom.xml
+++ b/wings/testing-silencer/pom.xml
@@ -13,7 +13,7 @@
     testing-silencer
     jar
 
-    Wings::Silencer::Test
+    Wings::Testing::Silencer
     Testing of Silencer
 
     
diff --git a/wings/testing-slardar/pom.xml b/wings/testing-slardar/pom.xml
index 817e8817..eacead0e 100644
--- a/wings/testing-slardar/pom.xml
+++ b/wings/testing-slardar/pom.xml
@@ -13,7 +13,7 @@
     testing-slardar
     jar
 
-    Wings::Slardar::Test
+    Wings::Testing::Slardar
     Testing of Slardar
 
     
diff --git a/wings/testing-warlock/pom.xml b/wings/testing-warlock/pom.xml
index 7e527e86..40dcab45 100644
--- a/wings/testing-warlock/pom.xml
+++ b/wings/testing-warlock/pom.xml
@@ -13,7 +13,7 @@
     testing-warlock
     jar
 
-    Wings::Warlock::Test
+    Wings::Testing::Warlock
     Testing of Warlock
 
     

From 444709855e79a95b80bf3085955fa446784b8139 Mon Sep 17 00:00:00 2001
From: trydofor 
Date: Thu, 15 Feb 2024 17:05:34 +0800
Subject: [PATCH 5/5] =?UTF-8?q?=E2=9C=A8=20safe=20table=20for=20jdbc=20#20?=
 =?UTF-8?q?6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 WingsBoot.t.md                                |  3 +-
 .../database/helper/JdbcTemplateHelper.java   | 96 +++++++++++++++++++
 .../database/helper/JournalJdbcHelper.java    | 35 ++-----
 .../spring/bean/FacelessConfiguration.java    |  4 +-
 .../helper/JdbcTemplateHelperTest.java        | 40 ++++++++
 .../database/TestingDatabaseHelper.java       |  6 +-
 .../warlock/security/SafeHttpHelper.java      |  1 +
 7 files changed, 154 insertions(+), 31 deletions(-)
 create mode 100644 wings/faceless/src/test/java/pro/fessional/wings/faceless/database/helper/JdbcTemplateHelperTest.java

diff --git a/WingsBoot.t.md b/WingsBoot.t.md
index f3bc1ba1..c51eeb7b 100644
--- a/WingsBoot.t.md
+++ b/WingsBoot.t.md
@@ -166,7 +166,7 @@ Use `t.md` as local [Test Management](https://www.jetbrains.com/help/idea/test-m
 * 12127 TestJooqMostSelectSample: paginate jooq sample
 * 12128 TestJooqMostSelectSample: paginate jdbc sample
 * 12129 TestJooqMostSelectSample: enum mapper sample
-* 12130 Tes[WingsBoot.t.md](WingsBoot.t.md)tJooqMostSelectSample: dsl function sample
+* 12130 TestJooqMostSelectSample: dsl function sample
 * 12131 FlywaveShardingTest: clean and init schema itself
 * 12132 FlywaveShardingTest: insert data in the writer
 * 12133 FlywaveShardingTest: check sharding on writer and reader
@@ -184,6 +184,7 @@ Use `t.md` as local [Test Management](https://www.jetbrains.com/help/idea/test-m
 * 12145 MockTstNormalTableTest: mock DSLContext to Dao instance
 * 12146 WingsEnumConvertersTest: enum converter
 * 12147 WingsRevisionTest: module root and path
+* 12148 JdbcTemplateHelperTest: safe table
 
 ## 13 Slardar
 
diff --git a/wings/faceless/src/main/java/pro/fessional/wings/faceless/database/helper/JdbcTemplateHelper.java b/wings/faceless/src/main/java/pro/fessional/wings/faceless/database/helper/JdbcTemplateHelper.java
index f03e766f..e347558d 100644
--- a/wings/faceless/src/main/java/pro/fessional/wings/faceless/database/helper/JdbcTemplateHelper.java
+++ b/wings/faceless/src/main/java/pro/fessional/wings/faceless/database/helper/JdbcTemplateHelper.java
@@ -1,11 +1,18 @@
 package pro.fessional.wings.faceless.database.helper;
 
+import lombok.extern.slf4j.Slf4j;
+import org.jetbrains.annotations.NotNull;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.core.ResultSetExtractor;
 
+import java.util.HashSet;
+import java.util.function.Function;
+
 /**
  * @author trydofor
  * @since 2024-01-25
  */
+@Slf4j
 public class JdbcTemplateHelper {
 
     public static final ResultSetExtractor FirstStringOrNull = rs -> rs.next() ? rs.getString(1) : null;
@@ -33,4 +40,93 @@ public class JdbcTemplateHelper {
         }
         return null;
     };
+
+    /**
+     * 
+     * where clause of PreparedStatement, must,
+     * - start with ' WHERE ' case-ignored
+     * - not empty
+     * - not contains ';'
+     * 
+ */ + public static String safeWhere(String where) { + if (where == null || where.isEmpty()) { + throw new IllegalArgumentException("where clause is empty"); + } + if (where.contains(";")) { + throw new IllegalArgumentException("where clause may be sql-injected, should not contains ';'"); + } + final String key = " WHERE "; + if (!where.regionMatches(true, 0, key, 0, key.length())) { + throw new IllegalArgumentException("missing ' WHERE ' in where clause"); + } + return where; + } + + protected static final HashSet SafeTables = new HashSet<>(); + protected static final HashSet QuotedTables = new HashSet<>(); + + /** + * the sql to list table, and get the table name at the first column + */ + @NotNull + protected static String ShowTableSql = "SHOW TABLES"; + + /** + * in mysql (not ANSI_QUOTES), return `table` + */ + @NotNull + protected static Function Quotes = (String name) -> "`" + name + "`"; + + public static void initSafeTable(JdbcTemplate tmpl) { + tmpl.query(ShowTableSql, rs -> { + String tbl = rs.getString(1); + log.info("init safe table={}", tbl); + + String lc = tbl.toLowerCase(); + String uc = tbl.toUpperCase(); + SafeTables.add(lc); + SafeTables.add(uc); + + QuotedTables.add(Quotes.apply(lc)); + QuotedTables.add(Quotes.apply(uc)); + }); + } + + /** + * whether the table is in the safe list + */ + public static boolean isSafeTable(String table) { + return SafeTables.contains(table) || QuotedTables.contains(table); + } + + /** + * quote name, e.g. `table` + */ + public static String safeName(@NotNull String name) { + return Quotes.apply(name); + } + + /** + * check and quote table + */ + public static String safeTable(String table) { + if (table == null || table.isEmpty()) { + throw new NullPointerException("table is empty"); + } + + int safe = 0; + if (SafeTables.contains(table)) { + safe = 1; + } + else if (QuotedTables.contains(table)) { + safe = 2; + } + + if (safe == 0) { + throw new IllegalArgumentException("unsafe table " + table); + } + + return safe == 1 ? Quotes.apply(table) : table; + } } diff --git a/wings/faceless/src/main/java/pro/fessional/wings/faceless/database/helper/JournalJdbcHelper.java b/wings/faceless/src/main/java/pro/fessional/wings/faceless/database/helper/JournalJdbcHelper.java index 19e1eade..9529a21b 100644 --- a/wings/faceless/src/main/java/pro/fessional/wings/faceless/database/helper/JournalJdbcHelper.java +++ b/wings/faceless/src/main/java/pro/fessional/wings/faceless/database/helper/JournalJdbcHelper.java @@ -62,8 +62,11 @@ public static String getJournalDateColumn(String table, Function } public static String getJournalDateColumn(JdbcTemplate tmpl, String table) { - //noinspection SqlConstantExpression - return getJournalDateColumn(table, s -> tmpl.query("SELECT * FROM " + s + " WHERE 1 = 0", filedJournal)); + return getJournalDateColumn(table, s -> { + String tbl = JdbcTemplateHelper.safeTable(s); + String sql = "SELECT * FROM " + tbl + " WHERE 1 = 0"; + return tmpl.query(sql, filedJournal); + }); } // jdbc @@ -110,8 +113,9 @@ public static int deleteWhere(JdbcTemplate tmpl, String table, Long commitId, St } public static int deleteWhere(JdbcTemplate tmpl, String table, Long commitId, LocalDateTime now, String where, Object... args) { - checkWhere(where); - checkTableName(table); + where = JdbcTemplateHelper.safeWhere(where); + table = JdbcTemplateHelper.safeTable(table); + String jf = getJournalDateColumn(tmpl, table); String journalSetter = " "; if (!jf.isEmpty()) { @@ -119,11 +123,9 @@ public static int deleteWhere(JdbcTemplate tmpl, String table, Long commitId, Lo journalSetter = ", " + jf + "=" + ldt + " "; } - @SuppressWarnings("SqlWithoutWhere") // checked String update = "UPDATE " + table + " SET " + COL_COMMIT_ID + "=" + commitId + journalSetter + where; tmpl.update(update, args); - @SuppressWarnings("SqlWithoutWhere") // checked String delete = "DELETE FROM " + table + " " + where; return tmpl.update(delete, args); } @@ -146,25 +148,4 @@ public static String getFieldName(String name) { int dot = name.lastIndexOf('.'); return dot < 0 ? name : name.substring(dot + 1); } - // //// - - public static void checkWhere(String where) { - if (where == null || where.isEmpty()) { - throw new IllegalArgumentException("where clause is empty"); - } - if (where.contains(";")) { - throw new IllegalArgumentException("where clause may be sql-injected, should not contains ';'"); - } - final String key = " WHERE "; - if (!where.regionMatches(true, 0, key, 0, key.length())) { - throw new IllegalArgumentException("missing ' WHERE ' in where clause"); - } - } - - public static void checkTableName(String table) { - if (table == null) throw new NullPointerException("table is null"); - if (table.contains(" ") || table.contains("\t") || table.contains("\r") || table.contains("\n") || table.contains("=") || table.contains(";")) { - throw new IllegalArgumentException("table is may be sql-injected"); - } - } } diff --git a/wings/faceless/src/main/java/pro/fessional/wings/faceless/spring/bean/FacelessConfiguration.java b/wings/faceless/src/main/java/pro/fessional/wings/faceless/spring/bean/FacelessConfiguration.java index 889e0f3e..8d23f0f5 100644 --- a/wings/faceless/src/main/java/pro/fessional/wings/faceless/spring/bean/FacelessConfiguration.java +++ b/wings/faceless/src/main/java/pro/fessional/wings/faceless/spring/bean/FacelessConfiguration.java @@ -8,6 +8,7 @@ import org.springframework.jdbc.core.JdbcTemplate; import pro.fessional.wings.faceless.database.DataSourceContext; import pro.fessional.wings.faceless.database.DataSourceContext.Customizer; +import pro.fessional.wings.faceless.database.helper.JdbcTemplateHelper; import pro.fessional.wings.faceless.database.manual.single.modify.commitjournal.CommitJournalModify; import pro.fessional.wings.faceless.database.manual.single.modify.commitjournal.impl.CommitJournalModifyJdbc; import pro.fessional.wings.faceless.service.flakeid.impl.FlakeIdLightIdImpl; @@ -50,7 +51,8 @@ public DataSourceContext dataSourceContext(DataSource current, List log.info("Faceless🦄 database-current-url=" + ctx.cacheJdbcUrl(ctx.getCurrent())); Map backends = ctx.getBackends(); for (Map.Entry e : backends.entrySet()) { - log.info("Faceless🦄 database-" + e.getKey() + "-url=" + ctx.cacheJdbcUrl(e.getValue())); + log.info("Faceless🦄 initSafeTable database-" + e.getKey() + "-url=" + ctx.cacheJdbcUrl(e.getValue())); + JdbcTemplateHelper.initSafeTable(new JdbcTemplate(e.getValue())); } return ctx; diff --git a/wings/faceless/src/test/java/pro/fessional/wings/faceless/database/helper/JdbcTemplateHelperTest.java b/wings/faceless/src/test/java/pro/fessional/wings/faceless/database/helper/JdbcTemplateHelperTest.java new file mode 100644 index 00000000..997ead8f --- /dev/null +++ b/wings/faceless/src/test/java/pro/fessional/wings/faceless/database/helper/JdbcTemplateHelperTest.java @@ -0,0 +1,40 @@ +package pro.fessional.wings.faceless.database.helper; + +import io.qameta.allure.TmsLink; +import lombok.Setter; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import pro.fessional.wings.faceless.database.DataSourceContext; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * @author trydofor + * @since 2024-02-15 + */ +@SpringBootTest +class JdbcTemplateHelperTest { + + @Setter(onMethod_ = {@Autowired}) + private DataSourceContext sourceContext; + + @Test + @TmsLink("12148") + void safeTable() { + // init the context + assertNotNull(sourceContext); + + assertTrue(JdbcTemplateHelper.isSafeTable("sys_light_sequence")); + assertTrue(JdbcTemplateHelper.isSafeTable("SYS_LIGHT_SEQUENCE")); + assertTrue(JdbcTemplateHelper.isSafeTable("`SYS_LIGHT_SEQUENCE`")); + assertFalse(JdbcTemplateHelper.isSafeTable("SYS_LIGHT_SEQUENCE`")); + + assertEquals("`sys_light_sequence`", JdbcTemplateHelper.safeTable("sys_light_sequence")); + assertEquals("`SYS_LIGHT_SEQUENCE`", JdbcTemplateHelper.safeTable("SYS_LIGHT_SEQUENCE")); + assertEquals("`SYS_LIGHT_SEQUENCE`", JdbcTemplateHelper.safeTable("`SYS_LIGHT_SEQUENCE`")); + } +} \ No newline at end of file diff --git a/wings/testing-faceless/src/main/java/pro/fessional/wings/testing/faceless/database/TestingDatabaseHelper.java b/wings/testing-faceless/src/main/java/pro/fessional/wings/testing/faceless/database/TestingDatabaseHelper.java index 940c1ce1..111eba17 100644 --- a/wings/testing-faceless/src/main/java/pro/fessional/wings/testing/faceless/database/TestingDatabaseHelper.java +++ b/wings/testing-faceless/src/main/java/pro/fessional/wings/testing/faceless/database/TestingDatabaseHelper.java @@ -6,6 +6,7 @@ import pro.fessional.mirana.data.Diff; import pro.fessional.mirana.io.InputStreams; import pro.fessional.wings.faceless.database.DataSourceContext; +import pro.fessional.wings.faceless.database.helper.JdbcTemplateHelper; import javax.sql.DataSource; import java.util.Arrays; @@ -62,9 +63,10 @@ public void cleanTable(DataSource dataSource, String info) { testcaseNotice("clean database " + info); JdbcTemplate tmpl = new JdbcTemplate(dataSource); tmpl.query("SHOW TABLES", rs -> { - String tbl = rs.getString(1); + String tbl = JdbcTemplateHelper.safeName(rs.getString(1)); testcaseNotice("DROP TABLE " + tbl); - tmpl.execute("DROP TABLE `" + tbl + "`"); + //noinspection SqlSourceToSinkFlow + tmpl.execute("DROP TABLE " + tbl); }); } diff --git a/wings/warlock-shadow/src/main/java/pro/fessional/wings/warlock/security/SafeHttpHelper.java b/wings/warlock-shadow/src/main/java/pro/fessional/wings/warlock/security/SafeHttpHelper.java index 247af3c4..33f19dd0 100644 --- a/wings/warlock-shadow/src/main/java/pro/fessional/wings/warlock/security/SafeHttpHelper.java +++ b/wings/warlock-shadow/src/main/java/pro/fessional/wings/warlock/security/SafeHttpHelper.java @@ -17,6 +17,7 @@ public class SafeHttpHelper { public static boolean isSafeRedirect(@NotNull String uri, Set hosts) { if (hosts == null || hosts.isEmpty()) return true; + //noinspection HttpUrlsUsage if (!StringUtils.startsWithIgnoreCase(uri, "http://") && !StringUtils.startsWithIgnoreCase(uri, "https://")) { return false;