Commit 5daf50f
fix(a2a-core, iframe-app): sanitize chat HTML against XSS, add build version metadata & enable coverage (#8860)
* fix(a2a-core): sanitize HTML output to prevent DOM XSS in Message component
Add DOMPurify sanitization to all dangerouslySetInnerHTML paths in
Message.tsx where marked.parse() and Prism.highlight() output was
rendered without sanitization, allowing XSS via crafted markdown.
- Add sanitizeHtml() utility with strict ALLOWED_TAGS/ATTR whitelist
- Sanitize all 6 dangerouslySetInnerHTML paths in Message.tsx
- Harden marked link renderer to block javascript: URLs
- Add 13 XSS prevention unit tests
MSRC Case 108268 / IcM 31000000555406
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat(iframe-app): inject build version metadata for traceability
Add git tag, SHA, branch, and build timestamp to the compiled output:
- <meta name="build-version"> tag in the HTML head
- __BUILD_*__ globals available in JS at runtime
- Console log at app startup with version info
Enables tracing any deployed iframe back to its source tag/commit.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(security): HTML-escape attribute values to prevent XSS
- Escape git metadata (tag, sha, branch) in vite build meta tag injection
- Escape href and title attributes in marked link renderer
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* test(a2a-core): add tests for HTML escaping and sanitization
- Add Message.escapeAttr tests for link attribute escaping
- Add sanitize.test.ts tests for style, form, event handlers, etc.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Update imports
* fix(a2a-core): enable coverage collection in vitest config
Align with other libs by using istanbul provider with enabled: true,
so coverage data is collected during test:lib CI runs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(a2a-core): fix TypeScript errors in Message test files
- Replace invalid 'delivered' status with 'sent' (MessageStatus type)
- Add missing 'status' property to AuthRequiredPart mock
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor(iframe-app): remove console.info build version log from main.tsx
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 8c9ec1e commit 5daf50f
File tree
12 files changed
+625
-464
lines changed- apps/iframe-app
- src
- libs/a2a-core
- src
- react/components/Message
- __tests__
- utils
12 files changed
+625
-464
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
1 | 7 | | |
2 | 8 | | |
3 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
7 | 46 | | |
8 | 47 | | |
9 | 48 | | |
| |||
22 | 61 | | |
23 | 62 | | |
24 | 63 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
41 | 91 | | |
42 | 92 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
48 | 98 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
49 | | - | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| 73 | + | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
78 | 84 | | |
79 | 85 | | |
80 | 86 | | |
81 | 87 | | |
82 | | - | |
83 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
84 | 91 | | |
85 | 92 | | |
86 | 93 | | |
| |||
495 | 502 | | |
496 | 503 | | |
497 | 504 | | |
498 | | - | |
| 505 | + | |
499 | 506 | | |
500 | 507 | | |
501 | 508 | | |
| |||
529 | 536 | | |
530 | 537 | | |
531 | 538 | | |
532 | | - | |
| 539 | + | |
533 | 540 | | |
534 | 541 | | |
535 | 542 | | |
| |||
555 | 562 | | |
556 | 563 | | |
557 | 564 | | |
558 | | - | |
| 565 | + | |
559 | 566 | | |
560 | 567 | | |
561 | 568 | | |
| |||
568 | 575 | | |
569 | 576 | | |
570 | 577 | | |
571 | | - | |
| 578 | + | |
572 | 579 | | |
573 | 580 | | |
574 | 581 | | |
575 | 582 | | |
576 | 583 | | |
577 | | - | |
| 584 | + | |
578 | 585 | | |
579 | 586 | | |
580 | 587 | | |
| |||
720 | 727 | | |
721 | 728 | | |
722 | 729 | | |
723 | | - | |
| 730 | + | |
724 | 731 | | |
725 | 732 | | |
726 | 733 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
Lines changed: 7 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| |||
Lines changed: 67 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
0 commit comments