Skip to content

Commit a1ac477

Browse files
docs: Add untrusted data security warnings to System.Speech APIs (#12149)
Add untrusted-data-instance-note to APIs that handle external XML/SRGS/SSML/audio files to warn developers about security risks when processing untrusted data. Changes: - SrgsDocument: Added class-level warning and warnings to constructors that accept file paths and XmlReader - Grammar: Added warnings to constructors that accept file paths and streams - PromptBuilder: Added warnings to AppendSsml(XmlReader) and AppendAudio(string) methods - GrammarBuilder: Added warnings to AppendRuleReference methods that accept file paths These APIs can load and parse external files which may contain corrupted or malicious content. The warnings direct developers to validate all inputs per OWASP guidelines. Co-authored-by: Pranav Gupta <[email protected]>
1 parent a737183 commit a1ac477

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

xml/System.Speech.Recognition.SrgsGrammar/SrgsDocument.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
<remarks>
3232
<format type="text/markdown"><![CDATA[
3333
34+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
35+
3436
## Remarks
3537
You can you construct an empty <xref:System.Speech.Recognition.SrgsGrammar.SrgsDocument> instance and build a grammar by adding instances of classes that represent SRGS elements, such as <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule>, <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf>,<xref:System.Speech.Recognition.SrgsGrammar.SrgsItem>, <xref:System.Speech.Recognition.SrgsGrammar.SrgsRuleRef>, <xref:System.Speech.Recognition.SrgsGrammar.SrgsSemanticInterpretationTag>, and <xref:System.Speech.Recognition.SrgsGrammar.SrgsToken>. You can also construct an <xref:System.Speech.Recognition.SrgsGrammar.SrgsDocument> instance from an existing SRGS-compliant XML grammar file, from an instance of <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule>, or from an instance of <xref:System.Speech.Recognition.GrammarBuilder>.
3638
@@ -284,6 +286,8 @@ recognizer.LoadGrammarAsync(g);
284286
<remarks>
285287
<format type="text/markdown"><![CDATA[
286288
289+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
290+
287291
## Examples
288292
The following example creates a new <xref:System.Speech.Recognition.SrgsGrammar.SrgsDocument> from the file named "srgsDocumentFile.xml".
289293
@@ -326,6 +330,8 @@ if (File.Exists(srgsDocumentFile))
326330
<remarks>
327331
<format type="text/markdown"><![CDATA[
328332
333+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
334+
329335
## Examples
330336
The following example creates a new instance of <xref:System.Speech.Recognition.SrgsGrammar.SrgsDocument> from an instance of <xref:System.Xml.XmlReader> that references the file "srgsDocumentFile.xml".
331337

xml/System.Speech.Recognition/Grammar.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,8 @@ private static Grammar CreateSrgsDocumentGrammar()
437437
<remarks>
438438
<format type="text/markdown"><![CDATA[
439439
440+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
441+
440442
## Remarks
441443
This constructor does not pass any parameters to the initialization handler, and the description should not define an initialization handler that requires arguments.
442444
@@ -540,6 +542,8 @@ private static Grammar CreateGrammarFromFile()
540542
<remarks>
541543
<format type="text/markdown"><![CDATA[
542544
545+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
546+
543547
## Remarks
544548
This constructor does not pass any parameters to the initialization handler, and the description should not define an initialization handler that requires arguments.
545549
@@ -774,6 +778,8 @@ namespace SampleRecognition
774778
<remarks>
775779
<format type="text/markdown"><![CDATA[
776780
781+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
782+
777783
## Remarks
778784
This constructor does not pass any parameters to the initialization handler, and the description should not define an initialization handler that requires arguments.
779785
@@ -1223,6 +1229,8 @@ private static Grammar CreateSrgsDocumentGrammar3()
12231229
<remarks>
12241230
<format type="text/markdown"><![CDATA[
12251231
1232+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
1233+
12261234
## Remarks
12271235
Parameters for an initialization handler may also be specified.
12281236

xml/System.Speech.Recognition/GrammarBuilder.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,6 +2002,8 @@ grammarWithDictation.Name = "Grammar with Dictation";
20022002
<remarks>
20032003
<format type="text/markdown"><![CDATA[
20042004
2005+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
2006+
20052007
## Remarks
20062008
The URI provided by the `path` argument may be local or remote. The application must have read access to the location of specified grammar files.
20072009
@@ -2089,6 +2091,8 @@ private static Grammar CreateCitiesGrammar1()
20892091
<remarks>
20902092
<format type="text/markdown"><![CDATA[
20912093
2094+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
2095+
20922096
## Remarks
20932097
The URI provided by the `path` argument may be local or remote. The application must have read access to the location of specified grammar files.
20942098

xml/System.Speech.Synthesis/PromptBuilder.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,13 @@ public void MySimpleText ()
200200
<Docs>
201201
<param name="path">A fully qualified path to the audio file.</param>
202202
<summary>Appends the specified audio file to the <see cref="T:System.Speech.Synthesis.PromptBuilder" />.</summary>
203-
<remarks>To be added.</remarks>
203+
<remarks>
204+
<format type="text/markdown"><![CDATA[
205+
206+
[!INCLUDE [untrusted-data-class-note](~/includes/untrusted-data-class-note.md)]
207+
208+
]]></format>
209+
</remarks>
204210
</Docs>
205211
</Member>
206212
<Member MemberName="AppendAudio">
@@ -960,6 +966,8 @@ namespace SampleSynthesis
960966
<remarks>
961967
<format type="text/markdown"><![CDATA[
962968
969+
[!INCLUDE [untrusted-data-instance-note](~/includes/untrusted-data-instance-note.md)]
970+
963971
## Remarks
964972
The SSML file must be an XML-format file that conforms to the [Speech Synthesis Markup Language (SSML) Version 1.0](https://www.w3.org/TR/speech-synthesis/) specification.
965973

0 commit comments

Comments
 (0)