Skip to content

Commit 0d837b0

Browse files
committed
fix: remove unescaped mustache interpolations in config template
Use escaped template interpolation in the OpenAPI configuration template to resolve the security scanner finding on triple-mustache rendering while preserving generated client behavior.
1 parent 8c0d10c commit 0d837b0

1 file changed

Lines changed: 24 additions & 24 deletions

File tree

.openapi-generator-templates/configuration.mustache

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class Configuration:
175175
:param password: Password for HTTP basic authentication.
176176
{{#hasHttpSignatureMethods}}
177177
:param signing_info: Configuration parameters for the HTTP signature security scheme.
178-
Must be an instance of {{{packageName}}}.signing.HttpSigningConfiguration
178+
Must be an instance of {{packageName}}.signing.HttpSigningConfiguration
179179
{{/hasHttpSignatureMethods}}
180180
:param server_index: Index to servers configuration.
181181
:param server_variables: Mapping with string values to replace variables in
@@ -206,7 +206,7 @@ class Configuration:
206206

207207
Workspace / sandbox scoping example:
208208

209-
conf = {{{packageName}}}.Configuration(
209+
conf = {{packageName}}.Configuration(
210210
api_key='sk_live_...',
211211
workspace_id='ws_abc',
212212
session_id='sb_xyz',
@@ -224,7 +224,7 @@ conf = {{{packageName}}}.Configuration(
224224

225225
Configure API client with HTTP basic authentication:
226226

227-
conf = {{{packageName}}}.Configuration(
227+
conf = {{packageName}}.Configuration(
228228
username='the-user',
229229
password='the-password',
230230
)
@@ -243,7 +243,7 @@ conf = {{{packageName}}}.Configuration(
243243
Configure API client with HTTP signature authentication. Use the 'hs2019' signature scheme,
244244
sign the HTTP requests with the RSA-SSA-PSS signature algorithm, and set the expiration time
245245
of the signature to 5 minutes after the signature has been created.
246-
Note you can use the constants defined in the {{{packageName}}}.signing module, and you can
246+
Note you can use the constants defined in the {{packageName}}.signing module, and you can
247247
also specify arbitrary HTTP headers to be included in the HTTP signature, except for the
248248
'Authorization' header, which is used to carry the signature.
249249

@@ -252,18 +252,18 @@ conf = {{{packageName}}}.Configuration(
252252
load balancers may add/modify/remove headers. Include the HTTP headers that you know
253253
are not going to be modified in transit.
254254

255-
conf = {{{packageName}}}.Configuration(
256-
signing_info = {{{packageName}}}.signing.HttpSigningConfiguration(
255+
conf = {{packageName}}.Configuration(
256+
signing_info = {{packageName}}.signing.HttpSigningConfiguration(
257257
key_id = 'my-key-id',
258258
private_key_path = 'rsa.pem',
259-
signing_scheme = {{{packageName}}}.signing.SCHEME_HS2019,
260-
signing_algorithm = {{{packageName}}}.signing.ALGORITHM_RSASSA_PSS,
261-
signed_headers = [{{{packageName}}}.signing.HEADER_REQUEST_TARGET,
262-
{{{packageName}}}.signing.HEADER_CREATED,
263-
{{{packageName}}}.signing.HEADER_EXPIRES,
264-
{{{packageName}}}.signing.HEADER_HOST,
265-
{{{packageName}}}.signing.HEADER_DATE,
266-
{{{packageName}}}.signing.HEADER_DIGEST,
259+
signing_scheme = {{packageName}}.signing.SCHEME_HS2019,
260+
signing_algorithm = {{packageName}}.signing.ALGORITHM_RSASSA_PSS,
261+
signed_headers = [{{packageName}}.signing.HEADER_REQUEST_TARGET,
262+
{{packageName}}.signing.HEADER_CREATED,
263+
{{packageName}}.signing.HEADER_EXPIRES,
264+
{{packageName}}.signing.HEADER_HOST,
265+
{{packageName}}.signing.HEADER_DATE,
266+
{{packageName}}.signing.HEADER_DIGEST,
267267
'Content-Type',
268268
'User-Agent'
269269
],
@@ -304,7 +304,7 @@ conf = {{{packageName}}}.Configuration(
304304
) -> None:
305305
"""Constructor
306306
"""
307-
self._base_path = "{{{basePath}}}" if host is None else host
307+
self._base_path = "{{basePath}}" if host is None else host
308308
"""Default Base url
309309
"""
310310
self.server_index = 0 if server_index is None and host is None else server_index
@@ -438,11 +438,11 @@ conf = {{{packageName}}}.Configuration(
438438
"""Options to pass down to the underlying urllib3 socket
439439
"""
440440

441-
self.datetime_format = "{{{datetimeFormat}}}"
441+
self.datetime_format = "{{datetimeFormat}}"
442442
"""datetime format
443443
"""
444444

445-
self.date_format = "{{{dateFormat}}}"
445+
self.date_format = "{{dateFormat}}"
446446
"""date format
447447
"""
448448

@@ -694,7 +694,7 @@ conf = {{{packageName}}}.Configuration(
694694
'type': 'bearer',
695695
'in': 'header',
696696
{{#bearerFormat}}
697-
'format': '{{{.}}}',
697+
'format': '{{.}}',
698698
{{/bearerFormat}}
699699
'key': 'Authorization',
700700
'value': 'Bearer ' + self.api_key
@@ -746,20 +746,20 @@ conf = {{{packageName}}}.Configuration(
746746
return [
747747
{{#servers}}
748748
{
749-
'url': "{{{url}}}",
750-
'description': "{{{description}}}{{^description}}No description provided{{/description}}",
749+
'url': "{{url}}",
750+
'description': "{{description}}{{^description}}No description provided{{/description}}",
751751
{{#variables}}
752752
{{#-first}}
753753
'variables': {
754754
{{/-first}}
755-
'{{{name}}}': {
756-
'description': "{{{description}}}{{^description}}No description provided{{/description}}",
757-
'default_value': "{{{defaultValue}}}",
755+
'{{name}}': {
756+
'description': "{{description}}{{^description}}No description provided{{/description}}",
757+
'default_value': "{{defaultValue}}",
758758
{{#enumValues}}
759759
{{#-first}}
760760
'enum_values': [
761761
{{/-first}}
762-
"{{{.}}}"{{^-last}},{{/-last}}
762+
"{{.}}"{{^-last}},{{/-last}}
763763
{{#-last}}
764764
]
765765
{{/-last}}

0 commit comments

Comments
 (0)