Skip to content

Commit 5ec4593

Browse files
committed
Merge branch 'main' into web-editor-junior-account
2 parents e0fb4a5 + 0af2b10 commit 5ec4593

File tree

407 files changed

+4045
-2207
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

407 files changed

+4045
-2207
lines changed

.lycheeignore

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,26 @@ https://support.arduino.cc/hc/*
66

77
# Returns 404 for some reason
88
https://create.arduino.cc/iot/*
9-
https://cloud.arduino.cc/home/registration
109
https://cloud.arduino.cc/home/resources
1110
https://cloud.arduino.cc/plans
11+
https://app.arduino.cc/resources
12+
https://app.arduino.cc/devices
13+
https://app.arduino.cc/things
14+
https://app.arduino.cc/dashboards
15+
https://app.arduino.cc/templates
16+
https://app.arduino.cc/registration
17+
https://app.arduino.cc/space
18+
https://app.arduino.cc/plan-usage
1219

1320
# "Network error: Forbidden" despite working redirect
1421
https://www.arduino.cc/en/Guide/Troubleshooting
1522
https://www.aftership.com/
1623

1724
# Returns 403 (but is accessible in browser)
1825
https://www.digikey.se/product-detail/en/jst-sales-america-inc/PHR-2/455-1165-ND/608607
26+
27+
# Returns [TIMEOUT]
28+
29+
https://www.st.com/resource/en/datasheet/lsm9ds1.pdf
30+
https://www.st.com/en/development-tools/stlink-v3set.html
31+
https://www.st.com/en/development-tools/stm32cubeprog.html

_deploy/package-lock.json

Lines changed: 376 additions & 299 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

_deploy/package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,27 @@
99
"author": "Sebastian Wikström",
1010
"license": "ISC",
1111
"dependencies": {
12-
"algoliasearch": "^4.13.1",
12+
"algoliasearch": "^4.23.2",
1313
"cli-color": "^2.0.3",
1414
"columnify": "^1.6.0",
1515
"commander": "^9.5.0",
1616
"dom-serializer": "^2.0.0",
1717
"domutils": "^3.0.1",
18+
"fast-diff": "^1.3.0",
1819
"fast-glob": "^3.2.11",
1920
"form-data": "^4.0.0",
2021
"front-matter": "^4.0.2",
2122
"highlight.js": "^11.5.1",
2223
"html-minifier": "^4.0.0",
2324
"html-to-text": "^8.2.1",
2425
"htmlparser2": "^8.0.1",
25-
"markdown-it": "^13.0.1",
26+
"markdown-it": "^14.0.0",
27+
"markdown-it-anchor": "^8.6.7",
28+
"markdown-it-attrs": "^4.1.6",
2629
"markdown-it-footnote": "^3.0.3",
30+
"markdown-it-github-alerts": "^0.3.0",
2731
"node-fetch": "^2.6.7",
28-
"node-zendesk": "^2.2.0"
32+
"node-zendesk": "^2.2.0",
33+
"uslug": "^1.0.4"
2934
}
3035
}

_deploy/zendesk.mjs

Lines changed: 102 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if (ZENDESK_USER && ZENDESK_PASS) {
1212
console.log('Zendesk credentials not found.');
1313
zendeskApiLimit = 200;
1414
}
15-
console.log(`API requests per minute: ${zendeskApiLimit}\n`);
15+
console.log(`API requests per minute: ${zendeskApiLimit}`);
1616

1717
const AlgoliaID = process.env.ALGOLIA_APPLICATION_ID;
1818
const AlgoliaSecret = process.env.ALGOLIA_INDEXER_KEY;
@@ -32,6 +32,8 @@ program
3232
.option('--cache-read [path]', 'read cached data', false)
3333
.option('--cache-save [path]', 'save cached data', false)
3434
.option('--html-save', 'save rendered HTML to disk', false)
35+
.option('--skip-algolia', 'skip all Algolia actions', false)
36+
.option('--html-diff', 'print rendered HTML diff', false)
3537
.option('-w, --wait <delay>', 'delay in seconds before fetching data')
3638
.option('-u, --syncIndex', 'check the entire search index for changes')
3739
program.parse();
@@ -43,8 +45,11 @@ const deployChanges = program.opts().deploy;
4345
const verbose = program.opts().verbose;
4446
const cacheRead = program.opts().cacheRead;
4547
const cacheSave = program.opts().cacheSave;
48+
const htmlSave = program.opts().htmlSave;
49+
const htmlDiff = program.opts().htmlDiff; // TODO
4650
const wait = program.opts().wait;
4751
const syncIndex = program.opts().syncIndex;
52+
var skipAlgolia = program.opts().skipAlgolia;
4853

4954
// Set up Zendesk client
5055
import { createClient as createZendeskClient } from 'node-zendesk';
@@ -62,8 +67,23 @@ const client = createZendeskClient({
6267

6368
// Algolia
6469
import algoliasearch from 'algoliasearch';
65-
const algoliaIndex = algoliasearch(AlgoliaID, AlgoliaSecret)
66-
.initIndex(AlgoliaIndexName);
70+
let algoliaIndex;
71+
if (!skipAlgolia) {
72+
algoliaIndex = algoliasearch(AlgoliaID, AlgoliaSecret)
73+
.initIndex(AlgoliaIndexName);
74+
try {
75+
var algoliaExists = await algoliaIndex.exists();
76+
if (algoliaExists) {
77+
console.log('Algolia index exists.');
78+
}
79+
} catch (error) {
80+
console.log('Algolia index does not exist, and will not be updated!');
81+
skipAlgolia = true;
82+
}
83+
}
84+
85+
// Empty line
86+
console.log();
6787

6888
// HTML
6989
import * as htmlparser2 from "htmlparser2";
@@ -73,8 +93,11 @@ import { convert } from 'html-to-text';
7393

7494
// Markdown
7595
import hljs from 'highlight.js'; // https://highlightjs.org/
76-
import markdownItFootnotes from 'markdown-it-footnote';
7796
import MarkdownIt from 'markdown-it';
97+
import markdownItFootnotes from 'markdown-it-footnote';
98+
import markdownItAnchor from 'markdown-it-anchor';
99+
import markdownItAttrs from 'markdown-it-attrs';
100+
import markdownItGitHubAlerts from 'markdown-it-github-alerts';
78101
const md = new MarkdownIt({
79102
html: true,
80103
smartquotes: true,
@@ -91,6 +114,23 @@ const md = new MarkdownIt({
91114
return ''; // use external default escaping
92115
}
93116
})
117+
.use(markdownItGitHubAlerts, {
118+
classPrefix: 'callout',
119+
icons: {
120+
note: '<span class="callout-icon callout-icon-note"></span>',
121+
tip: '<span class="callout-icon callout-icon-tip"></span>',
122+
important: '<span class="callout-icon callout-icon-important"></span>',
123+
warning: '<span class="callout-icon callout-icon-warning"></span>',
124+
caution: '<span class="callout-icon callout-icon-caution"></span>'
125+
}
126+
})
127+
.use(markdownItAnchor, {
128+
tabIndex: false
129+
})
130+
.use(markdownItAttrs, {
131+
allowedAttributes: ['id', 'class'],
132+
slugify: uslug
133+
})
94134
.use(markdownItFootnotes);
95135
import fm from 'front-matter';
96136

@@ -105,6 +145,8 @@ import fs from 'fs';
105145
const fsPromises = fs.promises;
106146
import fetch from 'node-fetch';
107147
import FormData from 'form-data';
148+
import uslug from 'uslug';
149+
import diff from 'fast-diff';
108150

109151
/* Run main function */
110152
main();
@@ -193,16 +235,10 @@ async function main() {
193235
throw error;
194236
}
195237

196-
/*
197-
console.log(clc.underline(`\nWaiting for 60 second(s)...`));
198-
await delay(60 * 1000);
199-
console.log('Done.\n');
200-
*/
201-
202238
console.log(clc.underline('\nFetching article attachments...'));
203239
try {
204240
await Promise.all([
205-
exTime(getAllAttachmentsSync(localArticles)).then(result => {
241+
exTime(getAllAttachmentsSync(zendeskArticles)).then(result => {
206242
console.log(`Fetched ${result.data.length} article attachment lists in ${result.exTime} ms.`);
207243
return result.data;
208244
})
@@ -565,7 +601,7 @@ async function deploy(zendeskSections, articles) {
565601
}
566602

567603
// Update Algolia
568-
if (translationUpdates || articleUpdates) {
604+
if ((translationUpdates || articleUpdates) && !skipAlgolia) {
569605
var sectionName = zendeskSections.find(s => s.id == a.zd.section_id).name;
570606
var contentClearText = convert(a.zd.body, {
571607
selectors: [
@@ -596,7 +632,9 @@ async function deploy(zendeskSections, articles) {
596632
}).wait();
597633
} catch (error) {
598634
console.error("Couldn't save object in Algolia");
599-
console.error(error);
635+
if (verbose) {
636+
console.error(error);
637+
}
600638
}
601639
}
602640
}));
@@ -627,7 +665,9 @@ async function deploy(zendeskSections, articles) {
627665
} catch (error) {
628666
console.error(`[${error.statusCode}] Archiving article "${article.zd.title}" (${article.zd.html_url})`);
629667
}
630-
await algoliaIndex.deleteObject(article.zd.url);
668+
if (!skipAlgolia) {
669+
await algoliaIndex.deleteObject(article.zd.url);
670+
}
631671
}
632672
}
633673

@@ -658,7 +698,17 @@ function hasChanges(article) {
658698
}
659699

660700
// Render body and compare
661-
if (!compareHTML(makeHTML(article.md.body, attachmentReplacements, true), article.zd.body)) {
701+
let localHTML = makeHTML(article.md.body, attachmentReplacements, true);
702+
let zdHTML = article.zd.body;
703+
if (htmlSave) {
704+
let htmlFilePath = article.md.filepath.concat('.html')
705+
fs.writeFileSync(root + '/' + htmlFilePath, localHTML, function (err) {
706+
if (err) {
707+
return console.log(err);
708+
}
709+
});
710+
}
711+
if (!compareHTML(localHTML, zdHTML)) {
662712
return true;
663713
}
664714

@@ -720,7 +770,7 @@ function getAttachmentReplacements(article) {
720770
if (zdAttachment) { // Match found
721771
attachmentReplacements.push({
722772
"src": src,
723-
"target": zdAttachment.content_url
773+
"target": zdAttachment.content_url // .replace('/' + zdAttachment.file_name, '')
724774
});
725775
// Remove processed
726776
zdAttachment.used = true;
@@ -904,17 +954,25 @@ function getAllAttachments(localArticles) {
904954
return Promise.all(attachment_promises);
905955
}
906956

907-
async function getAllAttachmentsSync(localArticles) {
957+
async function getAllAttachmentsSync(zendeskArticles) {
908958
var attachmentLists = [];
909-
for (const localArticle of localArticles) {
910-
const id = localArticle.attributes.id;
911-
const draft = localArticle.attributes.draft; // Will fail for drafts unless authenticated
959+
for (const zendeskArticle of zendeskArticles) {
960+
const id = zendeskArticle.id;
961+
const draft = zendeskArticle.draft; // Will fail for drafts unless authenticated
912962
if (id) {
963+
if (verbose) {
964+
console.log('Fetching attachments for article ' + id);
965+
}
913966
var result = await client.articleattachments.list(id);
914-
attachmentLists.push({
915-
"article_id": id,
916-
"attachments": result.article_attachments
917-
})
967+
if (!result.article_attachments) {
968+
console.log(`Warning: No article attachment array for article with ID ${id}`);
969+
console.log(result);
970+
} else {
971+
attachmentLists.push({
972+
"article_id": id,
973+
"attachments": result.article_attachments
974+
})
975+
}
918976
}
919977
}
920978
return attachmentLists;
@@ -1056,3 +1114,23 @@ async function deleteOrphanedSearchObjects(articles) {
10561114
const deleteResult = await algoliaIndex.deleteObjects(removeTheseObjectIDs)
10571115
console.log(`Deleted ${deleteResult.objectIDs.length} objects.`);
10581116
}
1117+
1118+
function printHtmlDiff(oldHtml, newHtml) {
1119+
let htmlDiff = diff(oldHtml, newHtml);
1120+
for (var s of htmlDiff) {
1121+
switch (s[0]) {
1122+
case diff.EQUAL:
1123+
console.log(s[1]);
1124+
break;
1125+
case diff.INSERT:
1126+
console.log(clc.bgGreen(s[1]))
1127+
break;
1128+
case diff.DELETE:
1129+
console.log(clc.bgRed(s[1]));
1130+
break;
1131+
default:
1132+
throw new Error("This shouldn't happen");
1133+
}
1134+
1135+
}
1136+
}

_linter/markdownlint/rules/hc002.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ var glob = require("glob");
99
const path = require('path');
1010
// TODO: https://stackoverflow.com/a/2186565
1111
const filePaths = glob.sync('content/**/*');
12+
let normPaths = [];
13+
for (var filePath of filePaths) {
14+
normPaths.push(path.normalize(filePath));
15+
}
1216

1317
module.exports = {
1418
"names": [ "HC002", "no-missing-images" ],
@@ -19,7 +23,7 @@ module.exports = {
1923
var dir = path.dirname(params.name);
2024
var imgPath = path.join(dir, token.attrs[0][1]);
2125

22-
if (!filePaths.includes(imgPath)) {
26+
if (!normPaths.includes(path.normalize(imgPath))) {
2327
addError(onError, token.lineNumber, null, imgPath);
2428
}
2529
});

content/About Arduino/Arduino Security Bulletins/ASEC-21-001-Vulnerabilities-in-Apache-Log4j.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ The Log4j library was removed in Arduino IDE 1.8.19.
2424
| 2021-12-14 | [1.8.17](https://github.com/arduino/Arduino/releases/tag/1.8.17) | Upgraded Log4j to 2.15.0, resolving [CVE-2021-44228](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44228) |
2525
| 2021-09-06 | [1.8.16](https://github.com/arduino/Arduino/releases/tag/1.8.16) | Using Log4j 2.12.0 |
2626

27-
> **Note:** The record creation date may reflect when the CVE ID was allocated or reserved, and does not necessarily indicate when this vulnerability was discovered, shared with the affected vendor, publicly disclosed, or updated in CVE.
27+
> [!NOTE]
28+
> The record creation date may reflect when the CVE ID was allocated or reserved, and does not necessarily indicate when this vulnerability was discovered, shared with the affected vendor, publicly disclosed, or updated in CVE.

content/About Arduino/Arduino Security Bulletins/ASEC-23-001-Vulnerabilities-in-Arduino-Create-Agent-1-3-2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The identified vulnerabilities may allow an attacker, with local access to the v
3535

3636
## Action Required
3737

38-
All users are advised to update the Arduino Create Agent to version 1.3.3 or later. An update is automatically initiated when visiting the Arduino Web Editor or when setting up a new device via the Arduino IoT Cloud. Alternatively, a manual update can be performed by downloading the new version of the software [here](https://github.com/arduino/arduino-create-agent/releases).
38+
All users are advised to update the Arduino Create Agent to version 1.3.3 or later. An update is automatically initiated when visiting the Arduino Cloud Editor or when setting up a new device in Arduino Cloud. Alternatively, a manual update can be performed by downloading the new version of the software [here](https://github.com/arduino/arduino-create-agent/releases).
3939

4040
## Additional information
4141

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: ASEC-23-002 - Vulnerabilities in Arduino Create Agent 1.3.5
3+
id: 11832917802652
4+
---
5+
6+
Bulletin ID: ASEC-23-002
7+
Date: Dec 13, 2023
8+
Product/Component: Arduino Create Agent
9+
Affected versions: &lt;= 1.3.5
10+
Fixed version: 1.3.6
11+
12+
## Summary
13+
14+
This security bulletin provides information on a series of security vulnerabilities that have been identified in the Arduino Create Agent version 1.3.5 and below.
15+
16+
Details on the security vulnerabilities and related advisories can be found below.
17+
18+
### Medium risk
19+
20+
* [CVE-2023-49296](https://www.cve.org/CVERecord?id=CVE-2023-49296): Reflected Cross-Site Scripting (CWE-35), CVSS v3.1 Base Score 7.3 (CVSS:3.1 AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:L)
21+
22+
## Impact
23+
24+
The identified vulnerabilities may allow an attacker to persuade a victim into clicking on a malicious link and perform a Reflected Cross-Site Scripting attack on the web interface of the create agent, which would allow the attacker to execute arbitrary browser client side code.
25+
26+
## Action Required
27+
28+
All users are advised to update the Arduino Create Agent to version 1.3.6 or later. An update is automatically initiated when visiting the Arduino Cloud Editor or when setting up a new device via Arduino Cloud. Alternatively, a manual update can be performed by downloading the new version of the software [here](https://github.com/arduino/arduino-create-agent/releases).
29+
30+
## Additional information
31+
32+
* [Security Advisory - Reflected Cross-Site Scripting](https://github.com/arduino/arduino-create-agent/security/advisories/GHSA-j5hc-wx84-844h) (CWE-79)
33+
34+
## Contact
35+
36+
If you encounter any issues or have questions regarding this security update, please contact our security team at [[email protected]](mailto:[email protected]).

0 commit comments

Comments
 (0)