@govtechsg/oobee 0.10.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/.dockerignore +22 -0
  2. package/.github/pull_request_template.md +11 -0
  3. package/.github/workflows/docker-test.yml +54 -0
  4. package/.github/workflows/image.yml +107 -0
  5. package/.github/workflows/publish.yml +18 -0
  6. package/.idea/modules.xml +8 -0
  7. package/.idea/purple-a11y.iml +9 -0
  8. package/.idea/vcs.xml +6 -0
  9. package/.prettierrc.json +12 -0
  10. package/.vscode/extensions.json +5 -0
  11. package/.vscode/settings.json +10 -0
  12. package/CODE_OF_CONDUCT.md +128 -0
  13. package/DETAILS.md +163 -0
  14. package/Dockerfile +60 -0
  15. package/INSTALLATION.md +146 -0
  16. package/INTEGRATION.md +785 -0
  17. package/LICENSE +22 -0
  18. package/README.md +587 -0
  19. package/SECURITY.md +5 -0
  20. package/__mocks__/mock-report.html +1431 -0
  21. package/__mocks__/mockFunctions.ts +32 -0
  22. package/__mocks__/mockIssues.ts +64 -0
  23. package/__mocks__/mock_all_issues/000000001.json +64 -0
  24. package/__mocks__/mock_all_issues/000000002.json +53 -0
  25. package/__mocks__/mock_all_issues/fake-file.txt +0 -0
  26. package/__tests__/logs.test.ts +25 -0
  27. package/__tests__/mergeAxeResults.test.ts +278 -0
  28. package/__tests__/utils.test.ts +118 -0
  29. package/a11y-scan-results.zip +0 -0
  30. package/eslint.config.js +53 -0
  31. package/exclusions.txt +2 -0
  32. package/gitlab-pipeline-template.yml +54 -0
  33. package/jest.config.js +1 -0
  34. package/package.json +96 -0
  35. package/scripts/copyFiles.js +44 -0
  36. package/scripts/install_oobee_dependencies.cmd +13 -0
  37. package/scripts/install_oobee_dependencies.command +101 -0
  38. package/scripts/install_oobee_dependencies.ps1 +110 -0
  39. package/scripts/oobee_shell.cmd +13 -0
  40. package/scripts/oobee_shell.command +11 -0
  41. package/scripts/oobee_shell.sh +55 -0
  42. package/scripts/oobee_shell_ps.ps1 +54 -0
  43. package/src/cli.ts +401 -0
  44. package/src/combine.ts +240 -0
  45. package/src/constants/__tests__/common.test.ts +44 -0
  46. package/src/constants/cliFunctions.ts +305 -0
  47. package/src/constants/common.ts +1840 -0
  48. package/src/constants/constants.ts +443 -0
  49. package/src/constants/errorMeta.json +319 -0
  50. package/src/constants/itemTypeDescription.ts +11 -0
  51. package/src/constants/oobeeAi.ts +141 -0
  52. package/src/constants/questions.ts +181 -0
  53. package/src/constants/sampleData.ts +187 -0
  54. package/src/crawlers/__tests__/commonCrawlerFunc.test.ts +51 -0
  55. package/src/crawlers/commonCrawlerFunc.ts +656 -0
  56. package/src/crawlers/crawlDomain.ts +877 -0
  57. package/src/crawlers/crawlIntelligentSitemap.ts +156 -0
  58. package/src/crawlers/crawlLocalFile.ts +193 -0
  59. package/src/crawlers/crawlSitemap.ts +356 -0
  60. package/src/crawlers/custom/extractAndGradeText.ts +57 -0
  61. package/src/crawlers/custom/flagUnlabelledClickableElements.ts +964 -0
  62. package/src/crawlers/custom/utils.ts +486 -0
  63. package/src/crawlers/customAxeFunctions.ts +82 -0
  64. package/src/crawlers/pdfScanFunc.ts +468 -0
  65. package/src/crawlers/runCustom.ts +117 -0
  66. package/src/index.ts +173 -0
  67. package/src/logs.ts +66 -0
  68. package/src/mergeAxeResults.ts +964 -0
  69. package/src/npmIndex.ts +284 -0
  70. package/src/screenshotFunc/htmlScreenshotFunc.ts +411 -0
  71. package/src/screenshotFunc/pdfScreenshotFunc.ts +762 -0
  72. package/src/static/ejs/partials/components/categorySelector.ejs +4 -0
  73. package/src/static/ejs/partials/components/categorySelectorDropdown.ejs +57 -0
  74. package/src/static/ejs/partials/components/pagesScannedModal.ejs +70 -0
  75. package/src/static/ejs/partials/components/reportSearch.ejs +47 -0
  76. package/src/static/ejs/partials/components/ruleOffcanvas.ejs +105 -0
  77. package/src/static/ejs/partials/components/scanAbout.ejs +263 -0
  78. package/src/static/ejs/partials/components/screenshotLightbox.ejs +13 -0
  79. package/src/static/ejs/partials/components/summaryScanAbout.ejs +141 -0
  80. package/src/static/ejs/partials/components/summaryScanResults.ejs +16 -0
  81. package/src/static/ejs/partials/components/summaryTable.ejs +20 -0
  82. package/src/static/ejs/partials/components/summaryWcagCompliance.ejs +94 -0
  83. package/src/static/ejs/partials/components/topFive.ejs +6 -0
  84. package/src/static/ejs/partials/components/wcagCompliance.ejs +70 -0
  85. package/src/static/ejs/partials/footer.ejs +21 -0
  86. package/src/static/ejs/partials/header.ejs +230 -0
  87. package/src/static/ejs/partials/main.ejs +40 -0
  88. package/src/static/ejs/partials/scripts/bootstrap.ejs +8 -0
  89. package/src/static/ejs/partials/scripts/categorySelectorDropdownScript.ejs +190 -0
  90. package/src/static/ejs/partials/scripts/categorySummary.ejs +141 -0
  91. package/src/static/ejs/partials/scripts/highlightjs.ejs +335 -0
  92. package/src/static/ejs/partials/scripts/popper.ejs +7 -0
  93. package/src/static/ejs/partials/scripts/reportSearch.ejs +248 -0
  94. package/src/static/ejs/partials/scripts/ruleOffcanvas.ejs +801 -0
  95. package/src/static/ejs/partials/scripts/screenshotLightbox.ejs +71 -0
  96. package/src/static/ejs/partials/scripts/summaryScanResults.ejs +14 -0
  97. package/src/static/ejs/partials/scripts/summaryTable.ejs +78 -0
  98. package/src/static/ejs/partials/scripts/utils.ejs +441 -0
  99. package/src/static/ejs/partials/styles/bootstrap.ejs +12375 -0
  100. package/src/static/ejs/partials/styles/highlightjs.ejs +54 -0
  101. package/src/static/ejs/partials/styles/styles.ejs +1843 -0
  102. package/src/static/ejs/partials/styles/summaryBootstrap.ejs +12458 -0
  103. package/src/static/ejs/partials/summaryHeader.ejs +70 -0
  104. package/src/static/ejs/partials/summaryMain.ejs +75 -0
  105. package/src/static/ejs/report.ejs +420 -0
  106. package/src/static/ejs/summary.ejs +47 -0
  107. package/src/static/mustache/.prettierrc +4 -0
  108. package/src/static/mustache/Attention Deficit.mustache +11 -0
  109. package/src/static/mustache/Blind.mustache +11 -0
  110. package/src/static/mustache/Cognitive.mustache +7 -0
  111. package/src/static/mustache/Colorblindness.mustache +20 -0
  112. package/src/static/mustache/Deaf.mustache +12 -0
  113. package/src/static/mustache/Deafblind.mustache +7 -0
  114. package/src/static/mustache/Dyslexia.mustache +14 -0
  115. package/src/static/mustache/Low Vision.mustache +7 -0
  116. package/src/static/mustache/Mobility.mustache +15 -0
  117. package/src/static/mustache/Sighted Keyboard Users.mustache +42 -0
  118. package/src/static/mustache/report.mustache +1709 -0
  119. package/src/types/print-message.d.ts +28 -0
  120. package/src/types/types.ts +46 -0
  121. package/src/types/xpath-to-css.d.ts +3 -0
  122. package/src/utils.ts +332 -0
  123. package/tsconfig.json +15 -0
@@ -0,0 +1,187 @@
1
+ // File used to hold sample data for unit testing
2
+
3
+ export const sampleXmlSitemap = `
4
+ <?xml version="1.0" encoding="UTF-8"?>
5
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
6
+ <!-- created with Free Online Sitemap Generator www.xml-sitemaps.com -->
7
+ <url>
8
+ <loc>http://www.google.com/</loc>
9
+ <lastmod>2023-01-17T02:49:19+00:00</lastmod>
10
+ <priority>1.00</priority>
11
+ </url>
12
+ <url>
13
+ <loc>http://www.google.com/intl/en/policies/privacy/</loc>
14
+ <lastmod>2020-05-26T07:00:00+00:00</lastmod>
15
+ <priority>0.80</priority>
16
+ </url>
17
+ <!-- <url>
18
+ <loc>http://www.google.com/intl/en/policies/terms/</loc>
19
+ <lastmod>2020-05-26T07:00:00+00:00</lastmod>
20
+ <priority>0.80</priority>
21
+ </url> -->
22
+ </urlset>`;
23
+
24
+ export const sampleXmlSitemapLinks = [
25
+ 'http://www.google.com/',
26
+ 'http://www.google.com/intl/en/policies/privacy/',
27
+ ];
28
+
29
+ // Source: https://www.feedforall.com/sample-feed.xml
30
+ export const sampleRssFeed = `<?xml version="1.0" encoding="windows-1252"?>
31
+ <rss version="2.0">
32
+ <channel>
33
+ <title>Sample Feed - Favorite RSS Related Software &amp; Resources</title>
34
+ <description>Take a look at some of FeedForAll&apos;s favorite software and resources for learning more about RSS.</description>
35
+ <link>http://www.feedforall.com</link>
36
+ <category domain="www.dmoz.com">Computers/Software/Internet/Site Management/Content Management</category>
37
+ <copyright>Copyright 2004 NotePage, Inc.</copyright>
38
+ <docs>http://blogs.law.harvard.edu/tech/rss</docs>
39
+ <language>en-us</language>
40
+ <lastBuildDate>Mon, 1 Nov 2004 13:17:17 -0500</lastBuildDate>
41
+ <managingEditor>marketing@feedforall.com</managingEditor>
42
+ <pubDate>Tue, 26 Oct 2004 14:06:44 -0500</pubDate>
43
+ <webMaster>webmaster@feedforall.com</webMaster>
44
+ <generator>FeedForAll Beta1 (0.0.1.8)</generator>
45
+ <image>
46
+ <url>http://www.feedforall.com/feedforall-temp.gif</url>
47
+ <title>FeedForAll Sample Feed</title>
48
+ <link>http://www.feedforall.com/industry-solutions.htm</link>
49
+ <description>FeedForAll Sample Feed</description>
50
+ <width>144</width>
51
+ <height>117</height>
52
+ </image>
53
+ <item>
54
+ <title>RSS Resources</title>
55
+ <description>Be sure to take a look at some of our favorite RSS Resources&lt;br&gt;
56
+ &lt;a href=&quot;http://www.rss-specifications.com&quot;&gt;RSS Specifications&lt;/a&gt;&lt;br&gt;
57
+ &lt;a href=&quot;http://www.blog-connection.com&quot;&gt;Blog Connection&lt;/a&gt;&lt;br&gt;
58
+ &lt;br&gt;</description>
59
+ <link>http://www.feedforall.com</link>
60
+ <pubDate>Tue, 26 Oct 2004 14:01:01 -0500</pubDate>
61
+ </item>
62
+ <item>
63
+ <title>Recommended Desktop Feed Reader Software</title>
64
+ <description>&lt;b&gt;FeedDemon&lt;/b&gt; enables you to quickly read and gather information from hundreds of web sites - without having to visit them. Don&apos;t waste any more time checking your favorite web sites for updates. Instead, use FeedDemon and make them come to you. &lt;br&gt;
65
+ More &lt;a href=&quot;http://store.esellerate.net/a.asp?c=1_SKU5139890208_AFL403073819&quot;&gt;FeedDemon Information&lt;/a&gt;</description>
66
+ <link>http://www.feedforall.com/feedforall-partners.htm</link>
67
+ <pubDate>Tue, 26 Oct 2004 14:03:25 -0500</pubDate>
68
+ </item>
69
+ <item>
70
+ <title>Recommended Web Based Feed Reader Software</title>
71
+ <description>&lt;b&gt;FeedScout&lt;/b&gt; enables you to view RSS/ATOM/RDF feeds from different sites directly in Internet Explorer. You can even set your Home Page to show favorite feeds. Feed Scout is a plug-in for Internet Explorer, so you won&apos;t have to learn anything except for how to press 2 new buttons on Internet Explorer toolbar. &lt;br&gt;
72
+ More &lt;a href=&quot;http://www.bytescout.com/feedscout.html&quot;&gt;Information on FeedScout&lt;/a&gt;&lt;br&gt;
73
+ &lt;br&gt;
74
+ &lt;br&gt;
75
+ &lt;b&gt;SurfPack&lt;/b&gt; can feature search tools, horoscopes, current weather conditions, LiveJournal diaries, humor, web modules and other dynamically updated content. &lt;br&gt;
76
+ More &lt;a href=&quot;http://www.surfpack.com/&quot;&gt;Information on SurfPack&lt;/a&gt;&lt;br&gt;</description>
77
+ <link>http://www.feedforall.com/feedforall-partners.htm</link>
78
+ <pubDate>Tue, 26 Oct 2004 14:06:44 -0500</pubDate>
79
+ </item>
80
+ </channel>
81
+ </rss>`;
82
+
83
+ export const sampleRssFeedLinks = [
84
+ 'http://www.feedforall.com',
85
+ 'http://www.feedforall.com/industry-solutions.htm',
86
+ 'http://www.feedforall.com/feedforall-partners.htm',
87
+ ];
88
+
89
+ // Source: https://www.ietf.org/rfc/rfc4287.txt
90
+ export const sampleAtomFeed = `<?xml version="1.0" encoding="utf-8"?>
91
+ <feed xmlns="http://www.w3.org/2005/Atom">
92
+ <title type="text">dive into mark</title>
93
+ <subtitle type="html">
94
+ A &lt;em&gt;lot&lt;/em&gt; of effort
95
+ went into making this effortless
96
+ </subtitle>
97
+ <updated>2005-07-31T12:29:29Z</updated>
98
+ <id>tag:example.org,2003:3</id>
99
+ <link rel="alternate" type="text/html"
100
+ hreflang="en" href="http://example.org/"/>
101
+ <link rel="self" type="application/atom+xml"
102
+ href="http://example.org/feed.atom"/>
103
+ <rights>Copyright (c) 2003, Mark Pilgrim</rights>
104
+ <generator uri="http://www.example.com/" version="1.0">
105
+ Example Toolkit
106
+ </generator>
107
+ <entry>
108
+ <title>Atom draft-07 snapshot</title>
109
+ <link rel="alternate" type="text/html"
110
+ href="http://example.org/2005/04/02/atom"/>
111
+ <link rel="enclosure" type="audio/mpeg" length="1337"
112
+ href="http://example.org/audio/ph34r_my_podcast.mp3"/>
113
+ <id>tag:example.org,2003:3.2397</id>
114
+ <updated>2005-07-31T12:29:29Z</updated>
115
+ <published>2003-12-13T08:29:29-04:00</published>
116
+ <author>
117
+ <name>Mark Pilgrim</name>
118
+ <uri>http://example.org/</uri>
119
+ <email>f8dy@example.com</email>
120
+ </author>
121
+ <contributor>
122
+ <name>Sam Ruby</name>
123
+ </contributor>
124
+ <contributor>
125
+ <name>Joe Gregorio</name>
126
+ </contributor>
127
+ <content type="xhtml" xml:lang="en"
128
+ xml:base="http://diveintomark.org/">
129
+ <div xmlns="http://www.w3.org/1999/xhtml">
130
+ <p><i>[Update: The Atom draft is finished.]</i></p>
131
+ </div>
132
+ </content>
133
+ </entry>
134
+ </feed>`;
135
+
136
+ export const sampleAtomFeedLinks = [
137
+ 'http://example.org/',
138
+ 'http://example.org/feed.atom',
139
+ 'http://example.org/2005/04/02/atom',
140
+ 'http://example.org/audio/ph34r_my_podcast.mp3',
141
+ ];
142
+
143
+ // Following format stated in https://developers.google.com/search/docs/crawling-indexing/sitemaps/build-sitemap#text
144
+ export const sampleTxtSitemap = `https://www.example.com/file1.html
145
+ https://www.example.com/file2.html
146
+ https://www.example.com/file3.html`;
147
+
148
+ export const sampleTxtSitemapLinks = [
149
+ 'https://www.example.com/file1.html',
150
+ 'https://www.example.com/file2.html',
151
+ 'https://www.example.com/file3.html',
152
+ ];
153
+
154
+ export const sampleNonStandardXmlSitemap = `<?xml version="1.0" encoding="UTF-8"?>
155
+ <contents>
156
+ <url>https://www.example.com/file1.html</url>
157
+ <link href='https://www.example.com/file2.html' />
158
+ <link>https://www.example.com/file3.html</link>
159
+ </contents>`;
160
+
161
+ export const sampleNonStandardXmlSitemapLinks = [
162
+ 'https://www.example.com/file1.html',
163
+ 'https://www.example.com/file2.html',
164
+ 'https://www.example.com/file3.html',
165
+ ];
166
+
167
+ export const sampleRssSitemap2 = `<?xml version="1.0" encoding="utf-8"?>
168
+ <feed xmlns="http://www.w3.org/2005/Atom">
169
+
170
+ <title>Example Feed</title>
171
+ <link href="http://example.org/"/>
172
+ <updated>2003-12-13T18:30:02Z</updated>
173
+ <author>
174
+ <name>John Doe</name>
175
+ </author>
176
+ <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
177
+
178
+ <entry>
179
+ <title>Atom-Powered Robots Run Amok</title>
180
+ <link href="http://example.org/2003/12/13/atom03"/>
181
+ <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
182
+ <updated>2003-12-13T18:30:02Z</updated>
183
+ <summary>Some text.</summary>
184
+ </entry>
185
+
186
+ </feed>
187
+ `;
@@ -0,0 +1,51 @@
1
+ /* eslint-disable no-underscore-dangle */
2
+ /* eslint-disable no-undef */
3
+ import privateFuncs from '../commonCrawlerFunc.js';
4
+ describe('test filter axe results', () => {
5
+ test('it works', () => {
6
+ // eslint-disable-next-line global-require
7
+ const filterAxeResults = privateFuncs.__get__('filterAxeResults');
8
+ // eslint-disable-next-line no-unused-expressions
9
+ const host = 'http://test.com/';
10
+ const results = {
11
+ violations: [
12
+ {
13
+ id: '1',
14
+ nodes: [{ html: '1-html1' }, { html: '1-html2' }],
15
+ help: 'help1',
16
+ impact: 'impact1',
17
+ helpUrl: 'helpurl1',
18
+ },
19
+ {
20
+ id: '2',
21
+ nodes: [{ html: '2-html1' }, { html: '2-html2' }],
22
+ help: 'help2',
23
+ impact: 'impact2',
24
+ helpUrl: 'helpurl2',
25
+ },
26
+ ],
27
+ url: `${host}api/path`,
28
+ };
29
+
30
+ const { url, page, errors } = filterAxeResults(results, host);
31
+
32
+ expect(url).toEqual(results.url);
33
+ expect(page).toEqual('api/path');
34
+ expect(errors).toEqual([
35
+ {
36
+ id: '1',
37
+ description: 'help1',
38
+ impact: 'impact1',
39
+ helpUrl: 'helpurl1',
40
+ fixes: [{ htmlElement: '1-html1' }, { htmlElement: '1-html2' }],
41
+ },
42
+ {
43
+ id: '2',
44
+ description: 'help2',
45
+ impact: 'impact2',
46
+ helpUrl: 'helpurl2',
47
+ fixes: [{ htmlElement: '2-html1' }, { htmlElement: '2-html2' }],
48
+ },
49
+ ]);
50
+ });
51
+ });