Skip to content

Commit d84ea3a

Browse files
committed
Merge branch 'develop' into sdp-sep-wallet-registration
# Conflicts: # helmchart/sdp/README.md
2 parents 72c43d2 + 73cf60c commit d84ea3a

File tree

7 files changed

+53
-17
lines changed

7 files changed

+53
-17
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- Fix HTML validation to allow apostrophes in invitation messages while maintaining security against XSS attacks [#930](https://github.com/stellar/stellar-disbursement-platform-backend/pull/930)
12+
13+
## [5.0.0](https://github.com/stellar/stellar-disbursement-platform-backend/releases/tag/5.0.0) ([diff](https://github.com/stellar/stellar-disbursement-platform-backend/compare/4.1.0...5.0.0))
14+
915
### Added
1016

1117
- Improve observability for the SDP service by adding the following :
@@ -15,7 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
1521
- [#818](https://github.com/stellar/stellar-disbursement-platform-backend/pull/818)
1622
- Add organization level MFA and ReCAPTCHA settings [#861](https://github.com/stellar/stellar-disbursement-platform-backend/pull/861)
1723
- Add trustlines for distribution account when provisioning tenant [#891](https://github.com/stellar/stellar-disbursement-platform-backend/pull/891)
18-
- Add support contract account disbursements [#922](https://github.com/stellar/stellar-disbursement-platform-backend/pull/922)
24+
- Add support for contract account disbursements [#922](https://github.com/stellar/stellar-disbursement-platform-backend/pull/922)
1925
- Add contract account support for direct payments [#924](https://github.com/stellar/stellar-disbursement-platform-backend/pull/924)
2026
- Add support for contract addresses for PATCH receiver [#925](https://github.com/stellar/stellar-disbursement-platform-backend/pull/925)
2127
- Mark tx failures due to archived entries as error [#926](https://github.com/stellar/stellar-disbursement-platform-backend/pull/926)
@@ -24,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
2430
- Decommissioned Event Broker Kafka support in favor of Scheduler for background jobs. [#914](https://github.com/stellar/stellar-disbursement-platform-backend/pull/914)
2531
- Allow configuring `resources` limits and requests for services in the Helm charts [#904](https://github.com/stellar/stellar-disbursement-platform-backend/pull/904)
2632
- Enable short linking by default [#916](https://github.com/stellar/stellar-disbursement-platform-backend/pull/916)
33+
- Make POST /wallets and PATCH /wallets permissions consistent [#909](https://github.com/stellar/stellar-disbursement-platform-backend/pull/909)
2734

2835
## [4.1.0](https://github.com/stellar/stellar-disbursement-platform-backend/releases/tag/4.1.0) ([diff](https://github.com/stellar/stellar-disbursement-platform-backend/compare/4.0.1...4.1.0))
2936

helmchart/sdp/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
apiVersion: v2
22
name: stellar-disbursement-platform
33
description: A Helm chart for the Stellar Disbursement Platform Backend (A.K.A. `sdp`)
4-
version: "4.1.1"
5-
appVersion: "4.1.0"
4+
version: "5.0.0"
5+
appVersion: "5.0.0"
66
type: application
77
maintainers:
88
- name: Stellar Development Foundation

helmchart/sdp/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ Configuration parameters for the SDP Core Service which is the core backend serv
196196
| `sdp.image` | Configuration related to the Docker image used by the SDP service. | |
197197
| `sdp.image.repository` | Docker image repository for the SDP backend service. | `stellar/stellar-disbursement-platform-backend` |
198198
| `sdp.image.pullPolicy` | Image pull policy for the SDP service. For locally built images, consider using "Never" or "IfNotPresent". | `Always` |
199-
| `sdp.image.tag` | Docker image tag for the SDP service. If set, this overrides the default value from `.Chart.AppVersion`. | `4.1.0` |
199+
| `sdp.image.tag` | Docker image tag for the SDP service. If set, this overrides the default value from `.Chart.AppVersion`. | `5.0.0` |
200200
| `sdp.deployment` | Configuration related to the deployment of the SDP service. | |
201201
| `sdp.deployment.annotations` | Annotations to be added to the deployment. | `nil` |
202202
| `sdp.deployment.podAnnotations` | Annotations specific to the pods. | `{}` |
@@ -327,7 +327,7 @@ Configuration parameters for the Dashboard. This is the user interface administr
327327
| `dashboard.route.mtnDomain` | Public domain/address of the multi-tenant Dashboard. This is a wild-card domain used for multi-tenant setups e.g. "*.sdp-dashboard.localhost.com". | `nil` |
328328
| `dashboard.route.port` | Primary port on which the Dashboard listens. | `80` |
329329
| `dashboard.image` | Configuration related to the Docker image used by the Dashboard. | |
330-
| `dashboard.image.fullName` | Full name of the Docker image. | `stellar/stellar-disbursement-platform-frontend:4.1.0` |
330+
| `dashboard.image.fullName` | Full name of the Docker image. | `stellar/stellar-disbursement-platform-frontend:5.0.0` |
331331
| `dashboard.image.pullPolicy` | Image pull policy for the dashboard. For locally built images, consider using "Never" or "IfNotPresent". | `Always` |
332332
| `dashboard.deployment` | Configuration related to the deployment of the Dashboard. | |
333333
| `dashboard.deployment.annotations` | Annotations to be added to the deployment. | `{}` |

helmchart/sdp/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ sdp:
135135
image:
136136
repository: stellar/stellar-disbursement-platform-backend
137137
pullPolicy: Always
138-
tag: "4.1.0"
138+
tag: "5.0.0"
139139

140140
## @extra sdp.deployment Configuration related to the deployment of the SDP service.
141141
## @param sdp.deployment.annotations Annotations to be added to the deployment.
@@ -450,7 +450,7 @@ dashboard:
450450
## @param dashboard.image.fullName Full name of the Docker image.
451451
## @param dashboard.image.pullPolicy Image pull policy for the dashboard. For locally built images, consider using "Never" or "IfNotPresent".
452452
image:
453-
fullName: stellar/stellar-disbursement-platform-frontend:4.1.0
453+
fullName: stellar/stellar-disbursement-platform-frontend:5.0.0
454454
pullPolicy: Always
455455

456456
## @extra dashboard.deployment Configuration related to the deployment of the Dashboard.

internal/utils/validation.go

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ import (
1919

2020
var (
2121
// RxPhone is a regex used to validate phone number, according with the E.164 standard https://en.wikipedia.org/wiki/E.164
22-
rxPhone = regexp.MustCompile(`^\+[1-9]{1}[0-9]{9,14}$`)
23-
rxOTP = regexp.MustCompile(`^\d{6}$`)
22+
rxPhone = regexp.MustCompile(`^\+[1-9]{1}[0-9]{9,14}$`)
23+
rxOTP = regexp.MustCompile(`^\d{6}$`)
24+
// Any HTML-like tag: <a ...>, </div>, <STYLE>...</STYLE>, etc.
25+
rxHTMLTag = regexp.MustCompile(`(?i)<\s*/?\s*[a-z][a-z0-9]*(\s+[^>]*)?>`)
26+
// "javascript:" URL scheme anywhere in the string.
27+
rxJSScheme = regexp.MustCompile(`(?i)\bjavascript\s*:`)
28+
rxCSSExpr = regexp.MustCompile(`(?i)\bexpression\s*\(`)
2429
ErrInvalidE164PhoneNumber = fmt.Errorf("the provided phone number is not a valid E.164 number")
2530
ErrEmptyPhoneNumber = fmt.Errorf("phone number cannot be empty")
2631
ErrEmptyEmail = fmt.Errorf("email field is required")
@@ -216,15 +221,20 @@ func ValidateURLScheme(link string, scheme ...string) error {
216221
return nil
217222
}
218223

219-
// ValidateNoHTML returns an error if the input contains any of the following HTML-related characters: [<, >, &, ', "],
220-
// either in encoded or decoded form.
221-
func ValidateNoHTML(input string) error {
222-
if escapedStr := html.EscapeString(input); escapedStr != input {
223-
return errors.New(`input contains one or more of the following HTML-related charactetes [<, >, &, ', "]`)
224+
// ValidateNoHTML returns an error if the input contains HTML tags, JavaScript schemes, or CSS expressions,
225+
// as detected by regular expressions, either in encoded or decoded form.
226+
func ValidateNoHTML(s string) error {
227+
if s == "" {
228+
return nil
224229
}
225230

226-
if unescapedStr := html.UnescapeString(input); unescapedStr != input {
227-
return errors.New("input contains HTML entities")
231+
if rxHTMLTag.MatchString(s) || rxJSScheme.MatchString(s) || rxCSSExpr.MatchString(s) {
232+
return errors.New("input contains HTML or active content")
233+
}
234+
235+
unescaped := html.UnescapeString(s)
236+
if rxHTMLTag.MatchString(unescaped) || rxJSScheme.MatchString(unescaped) || rxCSSExpr.MatchString(unescaped) {
237+
return errors.New("input contains HTML or active content")
228238
}
229239

230240
return nil

internal/utils/validation_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,25 @@ func Test_ValidateURLScheme(t *testing.T) {
381381
}
382382
}
383383

384+
func Test_ValidateNoHTML_Valid(t *testing.T) {
385+
validTestCases := []string{
386+
"Hello, World!",
387+
"This is a test string with numbers 1234567890.",
388+
"Special characters !?#$",
389+
"Mixed content: Hello123!@#",
390+
"Whitespace \n\t ",
391+
"This doesn't contain any HTML tags or scripts.",
392+
"Text with word expression but not as code.",
393+
}
394+
395+
for i, tc := range validTestCases {
396+
t.Run(fmt.Sprintf("valid/%d(%s)", i, tc), func(t *testing.T) {
397+
err := ValidateNoHTML(tc)
398+
require.NoError(t, err, "ValidateNoHTML(%q) returned an unexpected error: %v", tc, err)
399+
})
400+
}
401+
}
402+
384403
func Test_ValidateNoHTML(t *testing.T) {
385404
rawHTMLTestCases := []string{
386405
"<a href='evil.com'>Click here</a>",

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
// Version is the official version of this application. Whenever it's changed
1515
// here, it also needs to be updated at the `helmchart/Chart.yaml#appVersion“.
16-
const Version = "4.1.0"
16+
const Version = "5.0.0"
1717

1818
// GitCommit is populated at build time by
1919
// go build -ldflags "-X main.GitCommit=$GIT_COMMIT"

0 commit comments

Comments
 (0)