diff --git a/.github/workflows/semgrep.yml b/.github/workflows/semgrep.yml new file mode 100644 index 0000000000..7de157190c --- /dev/null +++ b/.github/workflows/semgrep.yml @@ -0,0 +1,26 @@ +name: Semgrep +on: + workflow_dispatch: {} + pull_request: {} + push: + branches: + - 'master' + - 'develop' + - 'release/[0-9].[0-9]+.[0-9]+' + paths: + - .github/workflows/semgrep.yml + schedule: + # random HH:MM to avoid a load spike on GitHub Actions at 00:00 + - cron: '17 18 * * *' +jobs: + semgrep: + name: semgrep/ci + runs-on: ubuntu-20.04 + env: + SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }} + container: + image: returntocorp/semgrep + if: (github.actor != 'dependabot[bot]') + steps: + - uses: actions/checkout@v3 + - run: semgrep ci diff --git a/WebContent/WEB-INF/snippet/changeContentText.jsp b/WebContent/WEB-INF/snippet/changeContentText.jsp index 450e787f20..22dcd9534b 100644 --- a/WebContent/WEB-INF/snippet/changeContentText.jsp +++ b/WebContent/WEB-INF/snippet/changeContentText.jsp @@ -22,5 +22,7 @@ onkeypress="if (event.keyCode==13) $('txtSet${componentId}').onclick();"/> -
Double click to close + +
Double click to close +
\ No newline at end of file diff --git a/build.gradle b/build.gradle index 5947ef1de5..e577577d05 100644 --- a/build.gradle +++ b/build.gradle @@ -96,7 +96,13 @@ task clearTomcat(type: Delete) { delete file(System.getenv("CATALINA_HOME") + "/webapps/ScadaBR.war") } -task deployTomcat(type: Copy) { +task existsScadaLTSWarFile { + doLast { + assert file("build/libs/Scada-LTS.war").exists() + } +} + +task deployTomcat(type: Copy, dependsOn: existsScadaLTSWarFile) { from "build/libs/" into System.getenv("CATALINA_HOME")+ "/webapps" include('Scada-LTS.war') diff --git a/scadalts-ui/src/locales/en.json b/scadalts-ui/src/locales/en.json index 3d23df6c63..59013031af 100644 --- a/scadalts-ui/src/locales/en.json +++ b/scadalts-ui/src/locales/en.json @@ -199,7 +199,7 @@ "datapointDetails.valueHistory.stats.max": "Maximum Value:", "datapointDetails.valueHistory.stats.min": "Minimum Value:", "datapointDetails.valueHistory.stats.sum": "Summary Value:", - "datapointDetails.valueHistory.stats.timeperiod": "Show history form", + "datapointDetails.valueHistory.stats.timeperiod": "Show history from", "datapointDetails.valueHistory.subtitle": "History", "datapointDetails.valueHistory.table.count": "Count", "datapointDetails.valueHistory.table.date": "Date", diff --git a/src/com/serotonin/mango/rt/dataImage/AnnotatedPointValueTime.java b/src/com/serotonin/mango/rt/dataImage/AnnotatedPointValueTime.java index 6d32f7840c..1c5dd2d14e 100644 --- a/src/com/serotonin/mango/rt/dataImage/AnnotatedPointValueTime.java +++ b/src/com/serotonin/mango/rt/dataImage/AnnotatedPointValueTime.java @@ -99,8 +99,9 @@ public String getSourceDescriptionKey() { return "annotation.user"; case SetPointSource.Types.POINT_LINK: return "annotation.pointLink"; + default: + return "annotation.unknown"; } - return null; } public String getSourceDescriptionArgument() { diff --git a/src/com/serotonin/mango/web/dwr/BaseDwr.java b/src/com/serotonin/mango/web/dwr/BaseDwr.java index 451330625a..4d8e003388 100644 --- a/src/com/serotonin/mango/web/dwr/BaseDwr.java +++ b/src/com/serotonin/mango/web/dwr/BaseDwr.java @@ -301,7 +301,7 @@ public Map getDateRangeDefaults(int periodType, int period) { } protected String getMessage(String key) { - return I18NUtils.getMessage(getResourceBundle(), key); + return I18NUtils.getMessage(getResourceBundle(), key == null ? "" : key); } protected String getMessage(LocalizableMessage message) { diff --git a/src/com/serotonin/mango/web/dwr/DataPointDetailsDwr.java b/src/com/serotonin/mango/web/dwr/DataPointDetailsDwr.java index 02b43fe603..d8e481e67d 100644 --- a/src/com/serotonin/mango/web/dwr/DataPointDetailsDwr.java +++ b/src/com/serotonin/mango/web/dwr/DataPointDetailsDwr.java @@ -71,9 +71,10 @@ public WatchListState getPointData() { PointValueTime pointValue = prepareBasePointState(Integer.toString(pointVO.getId()), state, pointVO, pointRT, model); setPrettyTextWithoutEqual(state, pointVO, model, pointValue); - if (state.getValue() != null) + if (state.getValue() != null) { + model.put("hideClosingHint", true); setChange(pointVO, state, pointRT, request, model, user); - + } setEvents(pointVO, user, model); setMessages(state, request, "watchListMessages", model); diff --git a/src/org/scada_lts/dao/MaintenanceEventDAO.java b/src/org/scada_lts/dao/MaintenanceEventDAO.java index bdb7281dec..f8f4956eba 100644 --- a/src/org/scada_lts/dao/MaintenanceEventDAO.java +++ b/src/org/scada_lts/dao/MaintenanceEventDAO.java @@ -188,7 +188,7 @@ public MaintenanceEventVO mapRow(ResultSet rs, int rowNum) throws SQLException { maintenanceEvent.setAlias(rs.getString(COLUMN_NAME_ALIAS)); maintenanceEvent.setAlarmLevel(rs.getInt(COLUMN_NAME_ALARM_LEVEL)); maintenanceEvent.setScheduleType(rs.getInt(COLUMN_NAME_SCHEDULE_TYPE)); - maintenanceEvent.setDisabled(DAO.charToBool(COLUMN_NAME_DISABLED)); + maintenanceEvent.setDisabled(DAO.charToBool(rs.getString(COLUMN_NAME_DISABLED))); maintenanceEvent.setActiveYear(rs.getInt(COLUMN_NAME_ACTIVE_YEAR)); maintenanceEvent.setActiveMonth(rs.getInt(COLUMN_NAME_ACTIVE_MONTH)); maintenanceEvent.setActiveDay(rs.getInt(COLUMN_NAME_ACTIVE_DAY)); diff --git a/src/org/scada_lts/dao/error/CustomSQLEroorCodesTranslator.java b/src/org/scada_lts/dao/error/CustomSQLEroorCodesTranslator.java index be6fcd3e5b..8556f52d28 100644 --- a/src/org/scada_lts/dao/error/CustomSQLEroorCodesTranslator.java +++ b/src/org/scada_lts/dao/error/CustomSQLEroorCodesTranslator.java @@ -5,6 +5,7 @@ import org.springframework.context.MessageSource; import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator; +@Deprecated(since = "2.7.5.4") public class CustomSQLEroorCodesTranslator extends SQLErrorCodeSQLExceptionTranslator { @Resource diff --git a/src/org/scada_lts/dao/model/UserAlarmLevel.java b/src/org/scada_lts/dao/model/UserAlarmLevel.java index cf06914910..4561601267 100644 --- a/src/org/scada_lts/dao/model/UserAlarmLevel.java +++ b/src/org/scada_lts/dao/model/UserAlarmLevel.java @@ -18,7 +18,9 @@ package org.scada_lts.dao.model; import com.serotonin.mango.rt.event.AlarmLevels; +import com.serotonin.mango.rt.event.EventInstance; import com.serotonin.mango.vo.User; +import org.scada_lts.web.ws.model.AlarmLevelMessage; /** * Model for buffering UnsilencedAlarmLevel @@ -43,6 +45,14 @@ public static UserAlarmLevel onlyUser(User user) { return new UserAlarmLevel(user, AlarmLevels.NONE); } + public static UserAlarmLevel fromEvent(User user, EventInstance eventInstance) { + return new UserAlarmLevel(user, eventInstance.getAlarmLevel()); + } + + public AlarmLevelMessage toAlarmLevelMessage() { + return new AlarmLevelMessage(alarmLevel); + } + public int getUserId() { return userId; } diff --git a/src/org/scada_lts/service/HighestAlarmLevelServiceWithCache.java b/src/org/scada_lts/service/HighestAlarmLevelServiceWithCache.java index 4be6261e2b..8de79871cf 100644 --- a/src/org/scada_lts/service/HighestAlarmLevelServiceWithCache.java +++ b/src/org/scada_lts/service/HighestAlarmLevelServiceWithCache.java @@ -68,19 +68,18 @@ public int getAlarmLevel(User user) { @Override public boolean doUpdateAlarmLevel(User user, EventInstance event, BiConsumer send) { - if(event.getAlarmLevel() > highestAlarmLevelCache.getAlarmLevel(user).getAlarmLevel()) { - this.lock.writeLock().lock(); - try { - if(event.getAlarmLevel() > highestAlarmLevelCache.getAlarmLevel(user).getAlarmLevel()) { - highestAlarmLevelCache.putAlarmLevel(user, new UserAlarmLevel(user, event.getAlarmLevel())); - send.accept(user, new AlarmLevelMessage(event.getAlarmLevel())); - return true; - } - } finally { - this.lock.writeLock().unlock(); + this.lock.writeLock().lock(); + try { + UserAlarmLevel userAlarmLevel = highestAlarmLevelCache.getAlarmLevel(user); + if(event.getAlarmLevel() > userAlarmLevel.getAlarmLevel()) { + highestAlarmLevelCache.putAlarmLevel(user, UserAlarmLevel.fromEvent(user, event)); + send.accept(user, AlarmLevelMessage.alarmLevelFromEvent(event)); + return true; } + return false; + } finally { + this.lock.writeLock().unlock(); } - return false; } @Override @@ -90,19 +89,18 @@ public boolean doSendAlarmLevel(User user, BiConsumer s @Override public boolean doRemoveAlarmLevel(User user, EventInstance event, BiConsumer send) { - if(event.getAlarmLevel() == highestAlarmLevelCache.getAlarmLevel(user).getAlarmLevel()) { - this.lock.writeLock().lock(); - try { - if (event.getAlarmLevel() == highestAlarmLevelCache.getAlarmLevel(user).getAlarmLevel()) { - highestAlarmLevelCache.removeAlarmLevel(user); - send.accept(user, new AlarmLevelMessage(highestAlarmLevelCache.getAlarmLevel(user).getAlarmLevel())); - return true; - } - } finally { - this.lock.writeLock().unlock(); + this.lock.writeLock().lock(); + try { + UserAlarmLevel userAlarmLevel = highestAlarmLevelCache.getAlarmLevel(user); + if (event.getAlarmLevel() == userAlarmLevel.getAlarmLevel()) { + highestAlarmLevelCache.removeAlarmLevel(user); + send.accept(user, highestAlarmLevelCache.getAlarmLevel(user).toAlarmLevelMessage()); + return true; } + return false; + } finally { + this.lock.writeLock().unlock(); } - return false; } @Override @@ -122,7 +120,7 @@ private boolean doSend(User user, BiConsumer send) { try { UserAlarmLevel alarmLevel = highestAlarmLevelCache.getAlarmLevel(user); if(alarmLevel.getAlarmLevel() >= AlarmLevels.NONE) { - send.accept(user, new AlarmLevelMessage(alarmLevel.getAlarmLevel())); + send.accept(user, alarmLevel.toAlarmLevelMessage()); return true; } return false; diff --git a/src/org/scada_lts/web/ws/model/AlarmLevelMessage.java b/src/org/scada_lts/web/ws/model/AlarmLevelMessage.java index 3c8bd45447..bcce79785c 100644 --- a/src/org/scada_lts/web/ws/model/AlarmLevelMessage.java +++ b/src/org/scada_lts/web/ws/model/AlarmLevelMessage.java @@ -1,5 +1,8 @@ package org.scada_lts.web.ws.model; +import com.serotonin.mango.rt.event.AlarmLevels; +import com.serotonin.mango.rt.event.EventInstance; + public class AlarmLevelMessage { private final int alarmLevel; @@ -13,6 +16,14 @@ public static AlarmLevelMessage empty() { return EMPTY; } + public static AlarmLevelMessage noneAlarmLevel() { + return new AlarmLevelMessage(AlarmLevels.NONE); + } + + public static AlarmLevelMessage alarmLevelFromEvent(EventInstance eventInstance) { + return new AlarmLevelMessage(eventInstance.getAlarmLevel()); + } + public int getAlarmlevel() { return alarmLevel; } diff --git a/webapp-resources/messages_de.properties b/webapp-resources/messages_de.properties index 8b0b689c12..ef9c64d5bd 100644 --- a/webapp-resources/messages_de.properties +++ b/webapp-resources/messages_de.properties @@ -3323,4 +3323,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen user.view.forceAdminTitle=The function is enforced by the Admin validate.1to255=Must be between 1 and 255 inclusive systemsettings.event.pendingLimit=Event Pending Limit -systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache \ No newline at end of file +systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache +annotation.unknown=Unknown diff --git a/webapp-resources/messages_en.properties b/webapp-resources/messages_en.properties index ad08ebc672..372f9d1950 100644 --- a/webapp-resources/messages_en.properties +++ b/webapp-resources/messages_en.properties @@ -3326,4 +3326,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen user.view.forceAdminTitle=The function is enforced by the Admin validate.1to255=Must be between 1 and 255 inclusive systemsettings.event.pendingLimit=Event Pending Limit -systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache \ No newline at end of file +systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache +annotation.unknown=Unknown diff --git a/webapp-resources/messages_es.properties b/webapp-resources/messages_es.properties index 8d0a7620d5..a58ebcf857 100644 --- a/webapp-resources/messages_es.properties +++ b/webapp-resources/messages_es.properties @@ -3366,4 +3366,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen user.view.forceAdminTitle=The function is enforced by the Admin validate.1to255=Must be between 1 and 255 inclusive systemsettings.event.pendingLimit=Event Pending Limit -systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache \ No newline at end of file +systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache +annotation.unknown=Unknown diff --git a/webapp-resources/messages_fi.properties b/webapp-resources/messages_fi.properties index f40779a0f6..2a4a842ea1 100644 --- a/webapp-resources/messages_fi.properties +++ b/webapp-resources/messages_fi.properties @@ -2485,8 +2485,8 @@ engUnit.86=imperial gallons per minute engUnit.87=liters per second engUnit.88=liters per minute engUnit.89=us gallons per minute -engUnit.90=degrees angular engUnit.91=degrees celsius per hour +engUnit.90=degrees angular engUnit.92=degrees celsius per minute engUnit.93=degrees fahrenheit per hour engUnit.94=degrees fahrenheit per minute @@ -3452,4 +3452,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen user.view.forceAdminTitle=The function is enforced by the Admin validate.1to255=Must be between 1 and 255 inclusive systemsettings.event.pendingLimit=Event Pending Limit -systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache \ No newline at end of file +systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache +annotation.unknown=Unknown diff --git a/webapp-resources/messages_fr.properties b/webapp-resources/messages_fr.properties index eabddedbc3..ab7e097ce5 100644 --- a/webapp-resources/messages_fr.properties +++ b/webapp-resources/messages_fr.properties @@ -3320,4 +3320,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen user.view.forceAdminTitle=The function is enforced by the Admin validate.1to255=Must be between 1 and 255 inclusive systemsettings.event.pendingLimit=Event Pending Limit -systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache \ No newline at end of file +systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache +annotation.unknown=Unknown diff --git a/webapp-resources/messages_lu.properties b/webapp-resources/messages_lu.properties index d9df177c4c..29c4774199 100644 --- a/webapp-resources/messages_lu.properties +++ b/webapp-resources/messages_lu.properties @@ -3339,4 +3339,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen user.view.forceAdminTitle=The function is enforced by the Admin validate.1to255=Must be between 1 and 255 inclusive systemsettings.event.pendingLimit=Event Pending Limit -systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache \ No newline at end of file +systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache +annotation.unknown=Unknown diff --git a/webapp-resources/messages_nl.properties b/webapp-resources/messages_nl.properties index 3a5648b264..62876a0c63 100644 --- a/webapp-resources/messages_nl.properties +++ b/webapp-resources/messages_nl.properties @@ -3442,4 +3442,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen user.view.forceAdminTitle=The function is enforced by the Admin validate.1to255=Must be between 1 and 255 inclusive systemsettings.event.pendingLimit=Event Pending Limit -systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache \ No newline at end of file +systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache +annotation.unknown=Unknown diff --git a/webapp-resources/messages_pl.properties b/webapp-resources/messages_pl.properties index 4e45609044..b5d43bd660 100644 --- a/webapp-resources/messages_pl.properties +++ b/webapp-resources/messages_pl.properties @@ -3464,4 +3464,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen user.view.forceAdminTitle=The function is enforced by the Admin validate.1to255=Must be between 1 and 255 inclusive systemsettings.event.pendingLimit=Event Pending Limit -systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache \ No newline at end of file +systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache +annotation.unknown=Unknown diff --git a/webapp-resources/messages_pt.properties b/webapp-resources/messages_pt.properties index 10e49dbde6..858b56157b 100644 --- a/webapp-resources/messages_pt.properties +++ b/webapp-resources/messages_pt.properties @@ -3478,4 +3478,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen user.view.forceAdminTitle=The function is enforced by the Admin validate.1to255=Must be between 1 and 255 inclusive systemsettings.event.pendingLimit=Event Pending Limit -systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache \ No newline at end of file +systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache +annotation.unknown=Unknown diff --git a/webapp-resources/messages_ru.properties b/webapp-resources/messages_ru.properties index b06951aea6..197fbc9534 100644 --- a/webapp-resources/messages_ru.properties +++ b/webapp-resources/messages_ru.properties @@ -3474,4 +3474,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen user.view.forceAdminTitle=The function is enforced by the Admin validate.1to255=Must be between 1 and 255 inclusive systemsettings.event.pendingLimit=Event Pending Limit -systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache \ No newline at end of file +systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache +annotation.unknown=Unknown diff --git a/webapp-resources/messages_zh.properties b/webapp-resources/messages_zh.properties index c7f194ab80..8ef6a11509 100644 --- a/webapp-resources/messages_zh.properties +++ b/webapp-resources/messages_zh.properties @@ -3427,4 +3427,5 @@ user.view.hideShortcutDisableFullScreen=Hide shortcut to disable full screen user.view.forceAdminTitle=The function is enforced by the Admin validate.1to255=Must be between 1 and 255 inclusive systemsettings.event.pendingLimit=Event Pending Limit -systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache \ No newline at end of file +systemsettings.event.pendingCacheEnabled=Enabled Event Pending Cache +annotation.unknown=Unknow