(#678 , #680)feat: add ability for asciidocParser to pass the krokiServerUrl #701
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
References - #678, #680 - Add VSCode rule to allow kroki-server-url by default for local server content
Note: This is the first part of #680 - Adding the ability for
asciidocParser
to pass thekrokiServerUrl
to theasciidoctorWebViewConverter
. This is done by loading the Asciidoctor document using theheader_only
before we instantiate theAsciidoctorWebViewConverter
inasciidocParser.ts
. Then sincekrokiServerUrl
should be defined at the parser level, and the value passed to the AsciidoctorWebViewConverter, I have added a new constructor argument named krokiServerUrl inasciidoctorwebviewconverter
.The next step will be to compute the CSP correctly. When enableKroki is true, we should always allow the krokiServerUrl no matter which security level is selected. -> Not sure 100% how I am going to make this work as CSP rules only get more restrictive.
Questions I have on this commit because I am very inexperienced with CSP rules and the complexity of the codebase here:
It was originally stated that we might need to "add
enableKroki
andkrokiServerUrl
to theAsciidocPreviewConfiguration
, then pass the configuration to thegetCspForResource
method" in #678 - Add VSCode rule to allow kroki-server-url by default for local server content #680. But it was later stated that we should not need to change the security level whenenableKroki
is true we should allow thekrokiServerUrl
no matter which security level is selected. This commit definesconst krokiServerUrl
in theasciidocParser
and adds a newkrokiServerUrl
constructor toAsciidoctorWebViewConverter
, but the cspRule will be looking forkrokiServerUrl
before theAsciidoctorWebViewConverter
class is defined. So my question is, is it necessary to definekrokiServerUrl
before theAsciidoctorWebViewConverter
class?For an example,
settings.json
section for the AsciiDoc extension looks like:If now, the Asciidoctor attribute
kroki-server-url
is passed to theasciidocParser
andAsciidoctorWebViewConverter
, do we still also want/need to pass the "enableKroki" value from the vscode configvscode.workspace.getConfiguration('asciidoc.extensions')
to theAsciidoctorWebViewConverter
to compute the else, if for the cspRule?@ggrossetie