Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): make vendored yaml ranges explicit

xd-bobod63b8be74112
diff --git a/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/_vendor/PyYAML-VERSION.txt b/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/_vendor/PyYAML-VERSION.txt
index 00da7c3f87..eb30dce260 100644
--- a/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/_vendor/PyYAML-VERSION.txt
+++ b/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/_vendor/PyYAML-VERSION.txt
@@ -1,2 +1,5 @@
PyYAML 6.0.3
Source: https://github.com/yaml/pyyaml/tree/6.0.3
+Local patch: reader.py expresses the YAML printable-codepoint ranges as ordinal
+comparisons instead of one equivalent regular expression, avoiding an ambiguous
+range warning from CodeQL.
diff --git a/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/_vendor/yaml/reader.py b/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/_vendor/yaml/reader.py
index 774b0219b5..894f137997 100644
--- a/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/_vendor/yaml/reader.py
+++ b/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/_vendor/yaml/reader.py
@@ -19,7 +19,7 @@ __all__ = ['Reader', 'ReaderError']
from .error import YAMLError, Mark
-import codecs, re
+import codecs
class ReaderError(YAMLError):
@@ -134,14 +134,17 @@ class Reader(object):
self.encoding = 'utf-8'
self.update(1)
- NON_PRINTABLE = re.compile('[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD\U00010000-\U0010ffff]')
def check_printable(self, data):
- match = self.NON_PRINTABLE.search(data)
- if match:
- character = match.group()
- position = self.index+(len(self.buffer)-self.pointer)+match.start()
- raise ReaderError(self.name, position, ord(character),
- 'unicode', "special characters are not allowed")
+ for offset, character in enumerate(data):
+ codepoint = ord(character)
+ if not (codepoint in (0x09, 0x0A, 0x0D, 0x85)
+ or 0x20 <= codepoint <= 0x7E
+ or 0xA0 <= codepoint <= 0xD7FF
+ or 0xE000 <= codepoint <= 0xFFFD
+ or 0x10000 <= codepoint <= 0x10FFFF):
+ position = self.index+(len(self.buffer)-self.pointer)+offset
+ raise ReaderError(self.name, position, codepoint,
+ 'unicode', "special characters are not allowed")
def update(self, length):
if self.raw_buffer is None:
diff --git a/scripts/__tests__/third-party-notices.test.mjs b/scripts/__tests__/third-party-notices.test.mjs
index 14657c71c2..dc00ee3adb 100644
--- a/scripts/__tests__/third-party-notices.test.mjs
+++ b/scripts/__tests__/third-party-notices.test.mjs
@@ -352,6 +352,14 @@ test("the bundled Skill validator accepts standard multiline YAML without extern
const skillDir = fs.mkdtempSync(path.join(os.tmpdir(), "cindy-skill-validator-"));
try {
+ const printableBoundaries = String.fromCodePoint(
+ 0xa0,
+ 0xd7ff,
+ 0xe000,
+ 0xfffd,
+ 0x10000,
+ 0x10ffff,
+ );
fs.writeFileSync(
path.join(skillDir, "SKILL.md"),
`---
@@ -362,6 +370,7 @@ metadata:
owner: "Cindy
team"
labels: [creator, validation]
+ printable-boundaries: "${printableBoundaries}"
---
# YAML regression
`,
@@ -376,6 +385,16 @@ metadata:
});
assert.equal(result.status, 0, `${result.stdout}\n${result.stderr}`);
assert.match(result.stdout, /Skill is valid!/);
+
+ fs.writeFileSync(
+ path.join(skillDir, "SKILL.md"),
+ "---\nname: yaml-regression\ndescription: invalid\0value\n---\n",
+ );
+ const rejected = spawnSync(command, [...prefix, "-S", validator, skillDir], {
+ encoding: "utf8",
+ });
+ assert.notEqual(rejected.status, 0);
+ assert.match(rejected.stdout, /special characters are not allowed/);
} finally {
fs.rmSync(skillDir, { recursive: true, force: true });
}