Editing business process groovy scripts in admin-portal
🌐 This document is available in both English and Ukrainian. Use the language toggle in the top right corner to switch between versions. |
1. Problem statement and solution
The development of the registry regulations business processes includes the development of Groovy scripts that reflect the logic of the business process steps. The admin portal allows the development of business processes for the registry regulations.
Developing Groovy scripts in specialized development tools, such as IDE (Desktop or Web versions), is much more efficient.
Extending the admin portal with the rich web editors for editing groovy scripts will improve the user experience to the level of using Desktop IDE tools, as well as reduce the time for continuous transfer of scripts to Desktop IDE for editing and back to BPMN.IO visual business process designer.
2. Glossary
-
LSP - Language Server Protocol
-
LS - Language Server
-
WS - WebSocket
-
WSS - WebSocket Secure
3. Actors
-
Registry regulations developer
4. Editor functionality
The following functionality is equally used for two functional scenarios: creating a new workflow step and editing or viewing an existing one. |
-
Auto-completion as a drop-down list of the call variants.
-
Display the results of code analysis for errors using the language server.
-
Display Hoover tooltip with javadoc information.
-
Use different colors when viewing code.
-
Auto-completion for DDM JUEL functions:
-
initiator
-
completer
-
system_user
-
submission
-
sign_submission
-
get_variable
-
set_variable
-
set_transient_variable
-
process_caller
-
message_payload
-
5. Basic principles
-
Monaco editor as a Web tool for the development of groovy scripts.
-
Using third-party Language Servers (LS) to get hints, the list for auto-completion and results of errors of semantic analysis of Groovy scripts.
-
Using Language Server Protocol for communication between Language Server and Monaco editor.
-
Using lsp4j for LS management (orchestration).
-
Transport communication protocol between Monaco editor and LS - WebSocket over HTTP (HTTPS).
-
Logical communication protocol (payload structure in the transport protocol messages) between Monaco editor and LS.
6. High-level design
6.1. Description and purpose of components
Name | Programming language | Description |
---|---|---|
JavaScript |
Visual browser-based code editor |
|
Remote LS’s |
Java, LSP4J |
Instances of LS services that use the LSP protocol and perform the client code check returning the test results in Json-RPC (LSP) format. |
LS Manager, Websocket Manager |
Java, Spring |
Spring boot web controller. Creates the required LS instances. Creates a WebSocket and uses the appropriate LS instance to analyze and validate code from the visual editor to the client. |
6.2. LSP communication
-
WSS protocol is used as transport protocol.
-
The LSP protocol, version 3.17 is used as RPC interaction.
6.2.1. WebSocket communication
-
WSS is used as a transport protocol.
-
To configure Web-socket communication from the UI layer side, the monaco-languageclient is used.
-
spring-websocket is used to organize the websocket backend part.
6.2.2. Number of LS instances
-
Each window with monaco editor uses its own individual web-socket instance to connect to LS.
-
Each web-socket uses an individual LS instance.
-
All LS instances are in the same JVM instance. Technically, each LS instance is a new instance with the
org.eclipse.lsp4j.services.LanguageServer
interface.
8. Scaling
In the current version of the service deployment, it is suggested to use only vertical scaling (RAM, CPU). Since the approach of placing all LSs within a single JVM is used, therefore, a significant increase in the use of computing resources is not expected during an increase in the number of the LS clients working at the same time.
Horizontal scaling is possible by adding Load Balancer for the LSP (WebSocket JSON-RPC) traffic. Out of scope. |
9. Threat modeling
Area | Name | Description | Limit Value |
---|---|---|---|
Kong |
WSS traffic through Kong |
Settings of the traffic through admin kong by using Upgrade headers. WebSocket kong manual |
|
Authorization during the handshake process |
Current authorization in admin kong. |
||
Maximum request size |
Limit for payload in LSP (JSON-RPC). Use Request Size Limiting |
65kb (30kb after SC) |
|
Socket timeout |
Idle time for the socket through which it automatically closes. Required configuration on both BE and FE side. Kong config property |
60s (should be by default) |
|
Socket open Rate limit |
Limit on the number of requests to create web-socket |
10 per minute per user |
|
Java application |
CORS configuration |
Configure CORS for the |
|
Chart configuration |
RAM limit |
Set the RAM limit by configuring resources.requests.memory in the Chart deployment |
1GB |
10. Technology stack
Name | Version | License | Description |
---|---|---|---|
0.34.1 |
Visual browser-based code editor |
||
4.0.3 |
The language server client connected to the Monaco editor and used to connect to remote language servers using LSP protocol) |
||
8.0.2 |
Transitive dependency with monaco-languageclient |
||
0.19 |
Library for managing LS instances. Used to run LS code. |
||
- |
Implements LSP protocol and performs Groovy code check returning test results in the Json-RPC format |
||
2.6.1 |
Spring Framework extension to simplify the construction of applications based on Spring due to the automatic configuration and spring boot starters |
||
2.6.1 |
Spring extension for Web Socket management in the server applications (uses spring-websocket:5.3.13) |
11. Control interface
BPMN.io will be extended with an additional button to call the modal window editing groovy scripts.
12. High-level development plan
12.1. Required expertise
-
Java
-
Javascript
-
DevOps
-
QA, AQA
12.1.1. Backend Java activities
-
Create Spring Boot-based backend service ddm-language-server.
-
Develop WebSocket proxy component.
-
Upgrade the LSP4J version to 0.19 for GroovyLanguageServer.
12.1.2. Javascript activities
-
Integration of Monaco Editor into the BPMN.IO business process editor.
-
Monaco Editor integration with ddm-language-server using monaco-languageclient.
12.1.3. DevOps activities
-
Onboard https://github.com/GroovyLanguageServer/groovy-language-server: add codebase into gerrit and create pipeline around
-
Create deploy-templates and Dockerfile for service ddm-language-server (openjdk based image).
-
AdminKong configuration for ddm-language-server traffic. Add websocket proxy headers to the Kong configuration.
-
Configuring Kong plugins to check the security limits.
-
Add the
languageServerUrl
variable toenvironment-js
with the relative ddm-laguage-server address.
13. Security
13.1. Business data
Data Category |
Description |
Privacy |
Integrity |
Accessibility |
Interim business process data containing open information |
Business form and process data that does not contain restricted information |
Low |
High |
Average |
Operational logs |
Lists of recorded/logged calls to the service and its operation logs |
Average |
High |
High |
13.3. Countermeasures against safety risks and compliance with safety requirements
Risk |
Security controls |
Implementation |
Priority |
Breach of data integrity and confidentiality during transmission |
Use of HTTPS and WSS |
Taken into account in the original design |
High |
Unsafe session termination on the server side |
During the user initiated exit from the system or in case of the automatic session timeout, any communication with the web socket must be terminated |
Not taken into account in the initial design |
High |
Denial of service due to depletion of computing resources (DoS) caused by the lack of restrictions for web sockets |
|
Taken into account in the initial design |
High |
Denial of service due to depletion of computing resources (DoS) caused by the lack of restrictions for the service at the openshift level |
|
Taken into account in the initial design |
High |
Denial of service due to depletion of computing resources (DoS) caused by the lack of restrictions for HTTP requests at the level of the Kong ingress controller |
|
Not taken into account in the initial design |
High |
Risk of backdoor in the language-server component |
|
Partially taken into account in the initial design. It is required to completely isolate the ddm-language-server service from the external network |
High |
Risk of executing vulnerability of interactive information systems (XSS) |
|
Taken into account in the initial design |
High |
Risk of disclosing technical information about the system |
|
Not taken into account in the initial design |
Medium |
Deserialization of unreliable data |
|
Not taken into account in the initial design |
Medium |
Risk of a group of web vulnerabilities and compliance with security requirements |
|
Not taken into account in the initial design |
Medium |
The risk of fixing in the system when exploiting a vulnerability to the system level and subsequent lateral movement. Compliance with the requirements. |
|
Not taken into account in the initial design |
Medium |
Insufficient logging and safety compliance |
|
Not taken into account in the initial design |
Low |
Misconfiguration of the service and/or framework |
|
Not taken into account in the initial design |
Low |
13.4. Comprehensive protection measures testing system
-
The repository with the source code must be onboarded to the vulnerability management system and undergo regular testing.
-
The basic image of the service must be scanned and not contain unresolved critical vulnerabilities.
-
The basic image must be placed in a trusted repository controlled by the organization.
-
The language-server technology should be added to the list of the used 3rd party products (inventory).