@eliceio/cdk-cli 1.2.1 → 1.3.0-contenttypes.0
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.
- package/README.md +59 -50
- package/es/cli.js +11 -2
- package/es/commands/build/index.js +12 -0
- package/es/commands/create/index.js +1 -0
- package/es/commands/create/scaffold.d.ts +2 -2
- package/es/commands/create/scaffold.js +3 -3
- package/es/commands/dev/index.d.ts +10 -1
- package/es/commands/dev/index.js +47 -7
- package/es/core/config.d.ts +20 -9
- package/es/core/config.js +53 -12
- package/es/core/project-check.d.ts +3 -2
- package/es/core/project-check.js +14 -3
- package/es/core/regex.d.ts +11 -0
- package/es/core/regex.js +41 -0
- package/es/core/sandbox.d.ts +26 -0
- package/es/core/sandbox.js +240 -30
- package/es/dev/check.d.ts +30 -0
- package/es/dev/check.js +224 -34
- package/es/dev/grading.d.ts +20 -1
- package/es/dev/grading.js +38 -7
- package/es/dev/host-page.js +1 -1
- package/es/dev/mock-api.d.ts +3 -1
- package/es/dev/mock-api.js +20 -11
- package/es/engines/vite/index.js +1 -1
- package/es/engines/vite/plugin.d.ts +2 -0
- package/es/engines/vite/plugin.js +33 -5
- package/es/rules/answers.d.ts +13 -0
- package/es/rules/answers.js +94 -0
- package/es/rules/check.js +70 -1
- package/es/rules/index.d.ts +1 -0
- package/es/rules/index.js +1 -0
- package/es/rules/size.d.ts +31 -0
- package/es/rules/size.js +58 -0
- package/es/rules/types.d.ts +12 -0
- package/es/rules.json.js +2 -2
- package/package.json +2 -2
- package/rules.json +32 -3
- package/skills/_shared/always.md +3 -3
- package/skills/_shared/references/00-what-the-person-decides.md +1 -1
- package/skills/_shared/references/02-design-the-material.md +10 -7
- package/skills/_shared/references/03-create-the-project.md +2 -1
- package/skills/_shared/references/05-screen-code.md +49 -22
- package/skills/_shared/references/06-using-the-quiz-template.md +7 -6
- package/skills/_shared/references/08-fix-check-errors.md +23 -22
- package/skills/_shared/references/09-check.md +7 -6
- package/skills/_shared/references/12-upload-with-the-material-mcp.md +13 -13
- package/skills/_shared/references/13-edit-screen-design.md +122 -0
- package/skills/_shared/references/14-layouts.md +96 -0
- package/skills/elice-content-check/SKILL.md +2 -2
- package/skills/elice-content-create/SKILL.md +1 -1
- package/skills/elice-content-migrate/SKILL.md +1 -1
- package/templates/_shared/lib/cdk-mock.d.ts +30 -3
- package/templates/_shared/lib/cdk-mock.js +88 -15
- package/templates/_shared/lib/elice-content-editor.js +89 -58
- package/templates/_shared/lib/elice-content.css +1313 -126
- package/templates/_shared/lib/elice-content.d.ts +162 -23
- package/templates/_shared/lib/elice-content.js +863 -82
- package/templates/_shared/lib/icons/empty-content.d.ts +2 -0
- package/templates/_shared/lib/icons/empty-content.js +11 -0
- package/templates/_shared/lib/icons/file-video.d.ts +2 -0
- package/templates/_shared/lib/icons/file-video.js +11 -0
- package/templates/_shared/lib/icons/file.d.ts +2 -0
- package/templates/_shared/lib/icons/file.js +11 -0
- package/templates/blank/README.md +5 -3
- package/templates/blank/edit.html +8 -2
- package/templates/blank/index.html +6 -1
- package/templates/blank/instructor.html +6 -1
- package/templates/blank/template.json +1 -1
- package/templates/quiz/README.md +28 -12
- package/templates/quiz/core/behaviors.d.ts +13 -7
- package/templates/quiz/core/behaviors.js +36 -51
- package/templates/quiz/core/editor.d.ts +10 -0
- package/templates/quiz/core/editor.js +334 -8
- package/templates/quiz/core/markdown.d.ts +4 -0
- package/templates/quiz/core/markdown.js +65 -11
- package/templates/quiz/core/model.d.ts +34 -1
- package/templates/quiz/core/model.js +86 -5
- package/templates/quiz/core/rich-text.d.ts +19 -0
- package/templates/quiz/core/rich-text.js +521 -0
- package/templates/quiz/edit.html +12 -3
- package/templates/quiz/index.html +12 -3
- package/templates/quiz/screens/edit.js +217 -48
- package/templates/quiz/screens/learn.js +90 -14
- package/templates/quiz/styles.css +840 -678
- package/templates/quiz/template.json +9 -2
- package/templates/quiz/ui/templates/edit.d.ts +18 -5
- package/templates/quiz/ui/templates/edit.js +309 -71
- package/templates/quiz/ui/templates/group.js +19 -8
- package/templates/quiz/ui/templates/order.js +25 -24
- package/templates/quiz/ui/templates/page.js +19 -8
- package/templates/quiz/ui/templates/question.js +2 -2
- package/templates/quiz/ui/texts.js +72 -25
- package/templates/quiz/ui/theme.css +8 -9
- package/templates/steps/README.md +77 -0
- package/templates/steps/commentary.txt +7 -0
- package/templates/steps/edit.html +21 -0
- package/templates/steps/gitignore +4 -0
- package/templates/steps/index.html +69 -0
- package/templates/steps/metadata.json +9 -0
- package/templates/steps/package.json +13 -0
- package/templates/steps/screens/edit.js +32 -0
- package/templates/steps/screens/learn.js +108 -0
- package/templates/steps/styles.css +54 -0
- package/templates/steps/template.json +6 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 정답 노출 검사(sec.answer-in-bundle)에 쓸 글: 편집 화면이 저장한 채점 설정(settings.grading)에서 그대로 찾을 수 있는 정답 글.
|
|
3
|
+
* 정답은 zip에 넣지 않는다 (ADR 0009). 화면 코드 · 학습 참고 내용에 같은 글이 있으면 학생이 zip에서 읽을 수 있다.
|
|
4
|
+
*
|
|
5
|
+
* - pattern: 정답 정규식 `^…$`에서 앞뒤 ^ · $와 바깥 묶음을 떼고, 맨 위 `|`로 나눈 갈래 중 정규식 기호가 없는 글만
|
|
6
|
+
* (`\.` 같은 이스케이프는 풀어서). `^(서울|Seoul)$` → 서울 · Seoul. `^\d+$`처럼 글이 아닌 갈래는 건너뜀
|
|
7
|
+
* - partial_pattern: 문항마다 정답 정규식 배열이라 원소마다 위와 같이
|
|
8
|
+
* - rubric: 평가 기준 글 전체
|
|
9
|
+
* 흔한 글과 겹치는 짧은 글은 뺀다: 한글이 든 글은 2자 미만, 그 밖(영문 · 숫자 등)은 3자 미만, 숫자만 3자 이하(100 · 0.5)
|
|
10
|
+
*/
|
|
11
|
+
function answerNeedles(grading) {
|
|
12
|
+
if (typeof grading !== 'object' || grading === null) return [];
|
|
13
|
+
const g = grading;
|
|
14
|
+
const out = [];
|
|
15
|
+
const key = g.answer_key ?? g.answerKey;
|
|
16
|
+
const keys = Array.isArray(key) ? key : [key];
|
|
17
|
+
for (const k of keys) if (typeof k === 'string') out.push(...regexLiterals(k));
|
|
18
|
+
if (typeof g.rubric === 'string') out.push(g.rubric.trim());
|
|
19
|
+
return [...new Set(out)].filter(s => s.length >= (/[가-힣]/.test(s) ? 2 : 3) && !/^\d{1,3}$/.test(s));
|
|
20
|
+
}
|
|
21
|
+
/** 정규식에서 그대로 찾을 수 있는 글 갈래 */
|
|
22
|
+
function regexLiterals(regex) {
|
|
23
|
+
let s = regex.trim();
|
|
24
|
+
if (s.startsWith('^')) s = s.slice(1);
|
|
25
|
+
if (s.endsWith('$') && !s.endsWith('\\$')) s = s.slice(0, -1);
|
|
26
|
+
s = stripOuterGroup(trimSpaces(s));
|
|
27
|
+
return splitTopLevel(s).map(trimSpaces).map(unescapeLiteral).filter(x => x !== null).map(x => x.trim());
|
|
28
|
+
}
|
|
29
|
+
/** 앞뒤 공백 허용(`\\s*` · `\\s+` · `\\s?`)을 뗀다 */
|
|
30
|
+
function trimSpaces(s) {
|
|
31
|
+
return s.replace(/^(?:\\s[*+?]?)+|(?:\\s[*+?]?)+$/g, '');
|
|
32
|
+
}
|
|
33
|
+
/** `(…)` · `(?:…)`가 전체를 감싸면 벗긴다 */
|
|
34
|
+
function stripOuterGroup(s) {
|
|
35
|
+
const open = s.startsWith('(?:') ? 3 : s.startsWith('(') && !s.startsWith('(?') ? 1 : 0;
|
|
36
|
+
if (!open || !s.endsWith(')')) return s;
|
|
37
|
+
let depth = 0;
|
|
38
|
+
for (let i = 0; i < s.length; i++) {
|
|
39
|
+
const c = s[i];
|
|
40
|
+
if (c === '\\') {
|
|
41
|
+
i++;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (c === '(') depth++;else if (c === ')') {
|
|
45
|
+
depth--;
|
|
46
|
+
if (depth === 0 && i < s.length - 1) return s; // 끝나기 전에 닫힘: 전체를 감싸지 않음
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return s.slice(open, -1);
|
|
50
|
+
}
|
|
51
|
+
/** 맨 위(괄호 · [] 밖)의 | 로 나눈다 */
|
|
52
|
+
function splitTopLevel(s) {
|
|
53
|
+
const parts = [];
|
|
54
|
+
let depth = 0;
|
|
55
|
+
let inClass = false;
|
|
56
|
+
let cur = '';
|
|
57
|
+
for (let i = 0; i < s.length; i++) {
|
|
58
|
+
const c = s[i] ?? '';
|
|
59
|
+
if (c === '\\') {
|
|
60
|
+
cur += c + (s[i + 1] ?? '');
|
|
61
|
+
i++;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (inClass) {
|
|
65
|
+
if (c === ']') inClass = false;
|
|
66
|
+
} else if (c === '[') inClass = true;else if (c === '(') depth++;else if (c === ')') depth--;else if (c === '|' && depth === 0) {
|
|
67
|
+
parts.push(cur);
|
|
68
|
+
cur = '';
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
cur += c;
|
|
72
|
+
}
|
|
73
|
+
parts.push(cur);
|
|
74
|
+
return parts;
|
|
75
|
+
}
|
|
76
|
+
/** 정규식 기호가 없는 글이면 이스케이프를 풀어 돌려주고, 기호(. * + ? ( ) [ ] { } | ^ $ \d 등)가 있으면 null */
|
|
77
|
+
function unescapeLiteral(alt) {
|
|
78
|
+
let out = '';
|
|
79
|
+
for (let i = 0; i < alt.length; i++) {
|
|
80
|
+
const c = alt[i] ?? '';
|
|
81
|
+
if (c === '\\') {
|
|
82
|
+
const n = alt[i + 1] ?? '';
|
|
83
|
+
if (/[A-Za-z0-9]/.test(n)) return null; // \d \s \w \b 같은 기호
|
|
84
|
+
out += n;
|
|
85
|
+
i++;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if ('.*+?()[]{}|^$'.includes(c)) return null;
|
|
89
|
+
out += c;
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export { answerNeedles, regexLiterals };
|
package/es/rules/check.js
CHANGED
|
@@ -4,6 +4,7 @@ import { parseManifest } from './manifest.js';
|
|
|
4
4
|
import { isUnsafePath, extname, resolveRef, globToRegExp } from './path.js';
|
|
5
5
|
import { lineAt, parseTags, extractRefs, classifyRef, FRAME_TAGS } from './refs.js';
|
|
6
6
|
import { compareVersions } from './semver.js';
|
|
7
|
+
import { screenSizeIssues, screenSizes, isLazyBundleFile } from './size.js';
|
|
7
8
|
import { lineSkipper } from './skip.js';
|
|
8
9
|
import { rules } from './spec.js';
|
|
9
10
|
|
|
@@ -70,6 +71,69 @@ function checkScreenCode(files, manifest, add) {
|
|
|
70
71
|
if (manifest.entries.edit && savesGrading && !/\buseSubmit\b|\.submit\s*\(/.test(uncommented)) add('grading.no-submit', `편집 화면(${manifest.entries.edit})이 채점 설정(settings.grading)을 저장하는데 화면 코드에 제출(app.useSubmit · sdk.submit)이 없습니다. 학생이 제출할 수 없어 채점 설정을 쓸 곳이 없고, LXP에서 '제출하면 완료' · '채점해 완료'를 골라도 학생이 완료할 수 없습니다. 학생 화면에 제출을 넣거나, 채점하지 않는 자료면 편집 화면에서 채점 설정(useGradingBlock · getGrading)을 빼 주세요.`);
|
|
71
72
|
if (manifest.entries.edit && !/\buseSave\b|\bsaveSettings\s*\(|\bsaveContent\s*\(/.test(code)) add('edit.no-save', `편집 화면(${manifest.entries.edit})을 켰는데 저장(app.useSave · sdk.saveSettings)이 없습니다. 편집한 내용이 LXP로 넘어가지 않습니다.`);
|
|
72
73
|
}
|
|
74
|
+
/** 레이아웃 값을 적는 곳: HTML 속성 · JS 문자열 속 속성, dataset.ecLayout, setAttribute('data-ec-layout', …) */
|
|
75
|
+
const LAYOUT_VALUE_RES = [/data-ec-(layout|region)\s*=\s*(["'])([^"'\n]*)\2/g, /\.dataset\.ec(Layout|Region)\s*=\s*(["'`])([^"'`\n]*)\2/g, /setAttribute\(\s*["']data-ec-(layout|region)["']\s*,\s*(["'`])([^"'`\n]*)\2/g];
|
|
76
|
+
/** 자작 단계 이동 버튼 글: "이전" · "‹ 이전" · "이전 단계"와 "다음" · "다음 ›" · "다음 단계" (글 전체가 이것뿐인 것만) */
|
|
77
|
+
const OWN_PREV_RES = [/>\s*(?:[◀‹←]\s*|<\s*)?이전(?:\s*단계)?\s*</g, /(["'`])\s*(?:[◀‹←<]\s*)?이전(?:\s*단계)?\s*\1/g];
|
|
78
|
+
const OWN_NEXT_RES = [/>\s*다음(?:\s*단계)?\s*(?:[▶›→]|>)?\s*</g, /(["'`])\s*다음(?:\s*단계)?\s*(?:[▶›→>]\s*)?\1/g];
|
|
79
|
+
/**
|
|
80
|
+
* 키트 레이아웃 · 스테퍼 규칙 (화면 HTML · JS, lib/ 밖). 묶은 모듈 본문은 원본으로 이미 검사해 건너뛴다.
|
|
81
|
+
* - layout.unknown: data-ec-layout · data-ec-region에 키트가 모르는 값 (CSS가 없어 배치가 안 됨)
|
|
82
|
+
* - layout.own-step-nav: 한 파일에 "이전" · "다음" 버튼 글이 같이 있음 (LXP 이전 · 다음 막대와 헷갈림, app.useStepper)
|
|
83
|
+
*/
|
|
84
|
+
function checkLayouts(files, spec, add) {
|
|
85
|
+
const decoder = new TextDecoder();
|
|
86
|
+
const known = {
|
|
87
|
+
layout: spec.layouts.content,
|
|
88
|
+
region: spec.layouts.regions
|
|
89
|
+
};
|
|
90
|
+
for (const f of files) {
|
|
91
|
+
if (!/\.(?:m?js|html?)$/i.test(f.path) || f.path.startsWith('lib/')) continue;
|
|
92
|
+
const raw = decoder.decode(f.data);
|
|
93
|
+
const text = /\.html?$/i.test(f.path) ? blankBundles(raw) : raw;
|
|
94
|
+
const skip = lineSkipper(text);
|
|
95
|
+
const found = (res, id) => {
|
|
96
|
+
for (const re of res) for (const m of text.matchAll(re)) {
|
|
97
|
+
const line = lineAt(text, m.index);
|
|
98
|
+
if (!skip.isSkipped(line, id)) return {
|
|
99
|
+
m,
|
|
100
|
+
line
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
};
|
|
105
|
+
for (const re of LAYOUT_VALUE_RES) for (const m of text.matchAll(re)) {
|
|
106
|
+
const kind = (m[1] ?? '').toLowerCase();
|
|
107
|
+
const value = (m[3] ?? '').trim();
|
|
108
|
+
if (value === '' || value.includes('${') || known[kind].includes(value)) continue;
|
|
109
|
+
const line = lineAt(text, m.index);
|
|
110
|
+
if (skip.isSkipped(line, 'layout.unknown')) continue;
|
|
111
|
+
add('layout.unknown', `data-ec-${kind}="${value}"는 키트가 모르는 값입니다 (가능: ${known[kind].join(' · ')}). 키트 CSS가 배치하지 않아 칸이 그냥 쌓입니다.`, f.path, line);
|
|
112
|
+
}
|
|
113
|
+
const prev = found(OWN_PREV_RES, 'layout.own-step-nav');
|
|
114
|
+
const next = prev && found(OWN_NEXT_RES, 'layout.own-step-nav');
|
|
115
|
+
if (prev && next) add('layout.own-step-nav', '화면 코드가 "이전" · "다음" 버튼을 직접 그리는 것 같습니다. LXP가 자료 아래에 수업 자료 사이 이전 · 다음 막대를 그려 학생이 헷갈립니다. 자료 안 단계는 키트 스테퍼(app.useStepper, 단계마다 <section data-ec-step>)를 써 주세요.', f.path, prev.line);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* 저장한 정답 글이 zip에 들어갈 파일(화면 HTML · JS · JSON · 학습 참고 내용 등 텍스트, 키트 lib/ 제외)에 그대로 있으면 경고.
|
|
120
|
+
* 파일마다 처음 한 곳만, 정답 값은 메시지에 싣지 않는다 (터미널 · JSON 출력이 기록으로 남을 수 있음)
|
|
121
|
+
*/
|
|
122
|
+
function checkAnswerLeak(files, needles, add) {
|
|
123
|
+
if (needles.length === 0) return;
|
|
124
|
+
const decoder = new TextDecoder();
|
|
125
|
+
for (const f of files) {
|
|
126
|
+
if (!/\.(?:m?js|html?|json|txt|md|csv|xml|svg|vtt)$/i.test(f.path) || f.path.startsWith('lib/')) continue;
|
|
127
|
+
if (f.path === 'metadata.json') continue;
|
|
128
|
+
const text = decoder.decode(f.data);
|
|
129
|
+
for (const needle of needles) {
|
|
130
|
+
const at = text.indexOf(needle);
|
|
131
|
+
if (at < 0) continue;
|
|
132
|
+
add('sec.answer-in-bundle', `편집 화면에 저장한 정답(채점 설정, ${needle.length}자)과 같은 글이 이 파일에 있습니다. zip 안 파일은 학생도 읽을 수 있으니 화면 코드 · 데이터 · 학습 참고 내용에서 빼 주세요 (정답은 편집 화면의 채점 설정에만).`, f.path, lineAt(text, at));
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
73
137
|
/**
|
|
74
138
|
* metadata.json build.template("quiz@1.0.0")이 이 CLI가 아는 템플릿 · 버전인지. 모르는 이름이거나 더 새 버전이면
|
|
75
139
|
* 이 CLI의 검사 · 가이드가 그 템플릿을 모를 수 있다 (경고만, 옛 zip · 템플릿 없이 만든 zip은 build.template이 없음)
|
|
@@ -93,7 +157,7 @@ function checkTemplate(manifest, opts, add) {
|
|
|
93
157
|
*/
|
|
94
158
|
const LEGACY_FILE_MESSAGES = {
|
|
95
159
|
'elice.config.json': 'elice.config.json은 더 쓰지 않습니다 (ADR 0011). 화면 · 학습 참고 내용(kind · screens · commentary)은 원본의 metadata.json에, 빌드 옵션 · template은 package.json "ecdk"에 둡니다. ecdk doctor --fix가 옮기고 elice.config.json을 지웁니다 (옮기기 전까지는 지금처럼 빌드됨).',
|
|
96
|
-
'content.json': 'content.json은 더 쓰지 않습니다 (기본 내용 파일 없음, ADR 0011). 화면은 편집 화면이 저장한 내용만 읽고, 저장하기 전에는 "
|
|
160
|
+
'content.json': 'content.json은 더 쓰지 않습니다 (기본 내용 파일 없음, ADR 0011). 화면은 편집 화면이 저장한 내용만 읽고, 저장하기 전에는 "학습 자료를 준비하고 있어요" 안내를 보입니다. 그 내용은 LXP에 올린 뒤 편집 화면에서 다시 넣고 파일을 지워 주세요. 화면 코드가 직접 fetch하는 데이터 파일이면 다른 이름(예: data.json)으로 바꿔 주세요.',
|
|
97
161
|
'grading.json': "grading.json은 더 쓰지 않습니다 (ADR 0011). 채점 방식 · 답은 LXP에 올린 뒤 편집 화면에서 정합니다 (ecdk dev의 '내용 편집'에 넣은 답은 .ecdk/settings.json, publish 스킬이 동의를 받아 업로드와 함께 보낼 수 있음). 파일은 지워 주세요 (zip에는 들어가지 않음)."
|
|
98
162
|
};
|
|
99
163
|
function checkLegacyFiles(opts, add) {
|
|
@@ -244,6 +308,8 @@ function checkFiles(input, opts = {}) {
|
|
|
244
308
|
checkTemplate(manifest, opts, message => add('build.template-unknown', message, spec.manifest.file));
|
|
245
309
|
checkScreenCode(files, manifest, (id, message) => add(id, message, spec.manifest.file));
|
|
246
310
|
}
|
|
311
|
+
checkLayouts(files, spec, add);
|
|
312
|
+
checkAnswerLeak(files, opts.answerNeedles ?? [], add);
|
|
247
313
|
checkLegacyFiles(opts, (message, path) => add('project.legacy-file', message, path));
|
|
248
314
|
checkSdk(manifest, spec, opts, add);
|
|
249
315
|
const entry = manifest?.entries.learn ?? spec.manifest.defaultEntry;
|
|
@@ -259,6 +325,7 @@ function checkFiles(input, opts = {}) {
|
|
|
259
325
|
const zipBytes = opts.zipBytes ?? estimateZipBytes(files);
|
|
260
326
|
if (files.length > maxFiles) add('limit.file-count', `파일이 ${files.length}개입니다 (한도 ${maxFiles}개).`);else if (files.length >= maxFiles * warnRatio) add('limit.near', `파일 ${files.length}개 · 한도 ${maxFiles}개에 가깝습니다.`);
|
|
261
327
|
if (zipBytes > maxZipBytes) add('limit.zip-size', `zip 크기가 ${fmtMB(zipBytes)}입니다 (한도 ${fmtMB(maxZipBytes)}). 영상은 비디오 자료로 따로 올리고 이미지는 줄여 주세요.`);else if (zipBytes >= maxZipBytes * warnRatio) add('limit.near', `zip ${fmtMB(zipBytes)} · 한도 ${fmtMB(maxZipBytes)}에 가깝습니다.`);
|
|
328
|
+
for (const issue of screenSizeIssues(screenSizes(files), spec)) add(issue.id, issue.message, issue.path);
|
|
262
329
|
// 경로 · 파일 종류
|
|
263
330
|
const byLower = new Map();
|
|
264
331
|
for (const f of files) {
|
|
@@ -344,6 +411,8 @@ function checkFiles(input, opts = {}) {
|
|
|
344
411
|
const kindOf = textKind(f.path);
|
|
345
412
|
if (!kindOf || matchExclude(f.path, spec.excluded.dev)) continue;
|
|
346
413
|
const text = decoder.decode(f.data);
|
|
414
|
+
// ecdk build가 나중에 받는 파일로 낸 묶음(npm 라이브러리 포함)은 HTML 안 묶음처럼 원본으로 이미 검사했다
|
|
415
|
+
if (kindOf === 'js' && isLazyBundleFile(text)) continue;
|
|
347
416
|
const tags = kindOf === 'html' ? parseTags(text) : [];
|
|
348
417
|
const vendor = isVendorFile(f.path);
|
|
349
418
|
// ecdk build가 묶은 모듈 본문(npm 라이브러리 포함)은 원본으로 이미 검사했다 (줄 번호는 그대로)
|
package/es/rules/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { checkFiles } from './check.js';
|
|
|
2
2
|
export { allowedOrigins, CONTENT_CSP, contentCsp, type CspValues, isAllowedExternal, } from './csp.js';
|
|
3
3
|
export { COMPLETION_POLICIES_IGNORED, graderTypeError, LEGACY_COMPLETION_FIELDS, LEGACY_COMPLETION_SCREENS, type ManifestWarning, parseManifest, serializeManifest, stripCompletionPolicy, } from './manifest.js';
|
|
4
4
|
export { globToRegExp } from './path.js';
|
|
5
|
+
export { isLazyBundleFile, LAZY_FILE_MARK, type ScreenSize, screenSizeIssues, screenSizes, } from './size.js';
|
|
5
6
|
export { commentOnlyLines, lineSkipper } from './skip.js';
|
|
6
7
|
export { rules, RULES_VERSION } from './spec.js';
|
|
7
8
|
export { findUnreferenced } from './unused.js';
|
package/es/rules/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export { checkFiles } from './check.js';
|
|
|
2
2
|
export { CONTENT_CSP, allowedOrigins, contentCsp, isAllowedExternal } from './csp.js';
|
|
3
3
|
export { COMPLETION_POLICIES_IGNORED, LEGACY_COMPLETION_FIELDS, LEGACY_COMPLETION_SCREENS, graderTypeError, parseManifest, serializeManifest, stripCompletionPolicy } from './manifest.js';
|
|
4
4
|
export { globToRegExp } from './path.js';
|
|
5
|
+
export { LAZY_FILE_MARK, isLazyBundleFile, screenSizeIssues, screenSizes } from './size.js';
|
|
5
6
|
export { commentOnlyLines, lineSkipper } from './skip.js';
|
|
6
7
|
export { RULES_VERSION, rules } from './spec.js';
|
|
7
8
|
export { findUnreferenced } from './unused.js';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ContentFile } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* ecdk build가 나중에 받는 파일(동적 import()로만 닿는 chunk)로 낸 일반 스크립트의 첫 글자.
|
|
4
|
+
* 검사는 HTML 안 묶음(`data-ecdk-bundle`)처럼 이 파일 본문을 건너뛴다 (원본으로 이미 검사함)
|
|
5
|
+
*/
|
|
6
|
+
export declare const LAZY_FILE_MARK = "/*ecdk-lazy*/";
|
|
7
|
+
/** ecdk build가 나중에 받는 파일로 낸 스크립트인지 */
|
|
8
|
+
export declare function isLazyBundleFile(text: string): boolean;
|
|
9
|
+
/** 화면(HTML) 하나를 열 때 받는 JS · CSS 크기 (바이트) */
|
|
10
|
+
export interface ScreenSize {
|
|
11
|
+
page: string;
|
|
12
|
+
/** HTML 안 `<script>` 본문 + `<script src>`로 받는 zip 안 파일 */
|
|
13
|
+
scriptBytes: number;
|
|
14
|
+
/** HTML 안 `<style>` 본문 + `<link rel="stylesheet">`로 받는 zip 안 파일 */
|
|
15
|
+
styleBytes: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* HTML마다 열 때 받는 JS · CSS. 나중에 받는 파일(import()로 부를 때 받음)은 넣지 않는다.
|
|
19
|
+
* 같은 파일을 여러 번 가리켜도 한 번만 센다
|
|
20
|
+
*/
|
|
21
|
+
export declare function screenSizes(files: ContentFile[]): ScreenSize[];
|
|
22
|
+
/** 화면을 열 때 받는 JS · CSS가 rules.json `limits.maxScreenBytes`를 넘으면 limit.screen-size 경고 */
|
|
23
|
+
export declare function screenSizeIssues(sizes: ScreenSize[], spec: {
|
|
24
|
+
limits: {
|
|
25
|
+
maxScreenBytes: number;
|
|
26
|
+
};
|
|
27
|
+
}): {
|
|
28
|
+
id: 'limit.screen-size';
|
|
29
|
+
message: string;
|
|
30
|
+
path: string;
|
|
31
|
+
}[];
|
package/es/rules/size.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { resolveRef } from './path.js';
|
|
2
|
+
import { parseTags, classifyRef } from './refs.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ecdk build가 나중에 받는 파일(동적 import()로만 닿는 chunk)로 낸 일반 스크립트의 첫 글자.
|
|
6
|
+
* 검사는 HTML 안 묶음(`data-ecdk-bundle`)처럼 이 파일 본문을 건너뛴다 (원본으로 이미 검사함)
|
|
7
|
+
*/
|
|
8
|
+
const LAZY_FILE_MARK = '/*ecdk-lazy*/';
|
|
9
|
+
/** ecdk build가 나중에 받는 파일로 낸 스크립트인지 */
|
|
10
|
+
function isLazyBundleFile(text) {
|
|
11
|
+
return text.startsWith(LAZY_FILE_MARK);
|
|
12
|
+
}
|
|
13
|
+
const BODY = tag => new RegExp(`<${tag}\\b[^>]*>([\\s\\S]*?)<\\/${tag}\\s*>`, 'gi');
|
|
14
|
+
const byteLength = text => new TextEncoder().encode(text).byteLength;
|
|
15
|
+
/**
|
|
16
|
+
* HTML마다 열 때 받는 JS · CSS. 나중에 받는 파일(import()로 부를 때 받음)은 넣지 않는다.
|
|
17
|
+
* 같은 파일을 여러 번 가리켜도 한 번만 센다
|
|
18
|
+
*/
|
|
19
|
+
function screenSizes(files) {
|
|
20
|
+
const decoder = new TextDecoder();
|
|
21
|
+
const byPath = new Map(files.filter(f => !f.dir).map(f => [f.path, f]));
|
|
22
|
+
const sizes = [];
|
|
23
|
+
for (const f of files) {
|
|
24
|
+
if (f.dir || !/\.html?$/i.test(f.path)) continue;
|
|
25
|
+
const html = decoder.decode(f.data);
|
|
26
|
+
const inline = tag => [...html.replace(/<!--[\s\S]*?-->/g, '').matchAll(BODY(tag))].reduce((n, m) => n + byteLength(m[1] ?? ''), 0);
|
|
27
|
+
const linked = {
|
|
28
|
+
script: new Set(),
|
|
29
|
+
style: new Set()
|
|
30
|
+
};
|
|
31
|
+
for (const t of parseTags(html)) {
|
|
32
|
+
const ref = t.name === 'script' ? t.attrs.get('src') : t.name === 'link' && /\bstylesheet\b/i.test(t.attrs.get('rel') ?? '') ? t.attrs.get('href') : undefined;
|
|
33
|
+
if (!ref || classifyRef(ref.trim()) !== 'local') continue;
|
|
34
|
+
const path = resolveRef(f.path, ref.trim().replace(/[?#].*$/, ''));
|
|
35
|
+
if (path !== null && byPath.has(path)) linked[t.name === 'script' ? 'script' : 'style'].add(path);
|
|
36
|
+
}
|
|
37
|
+
const sum = paths => [...paths].reduce((n, p) => n + (byPath.get(p)?.data.byteLength ?? 0), 0);
|
|
38
|
+
sizes.push({
|
|
39
|
+
page: f.path,
|
|
40
|
+
scriptBytes: inline('script') + sum(linked.script),
|
|
41
|
+
styleBytes: inline('style') + sum(linked.style)
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return sizes;
|
|
45
|
+
}
|
|
46
|
+
const MB = 1024 * 1024;
|
|
47
|
+
const fmt = n => n >= MB ? `${(n / MB).toFixed(1)}MB` : `${(n / 1024).toFixed(1)}KB`;
|
|
48
|
+
/** 화면을 열 때 받는 JS · CSS가 rules.json `limits.maxScreenBytes`를 넘으면 limit.screen-size 경고 */
|
|
49
|
+
function screenSizeIssues(sizes, spec) {
|
|
50
|
+
const max = spec.limits.maxScreenBytes;
|
|
51
|
+
return sizes.filter(s => s.scriptBytes + s.styleBytes > max).map(s => ({
|
|
52
|
+
id: 'limit.screen-size',
|
|
53
|
+
path: s.page,
|
|
54
|
+
message: `${s.page}를 열 때 받는 JS · CSS가 ${fmt(s.scriptBytes + s.styleBytes)}입니다 (JS ${fmt(s.scriptBytes)} · CSS ${fmt(s.styleBytes)}, 기준 ${fmt(max)}). 학생 화면이 늦게 열립니다. 큰 라이브러리는 쓸 때 import()로 부르면 ecdk build가 나중에 받는 파일로 따로 냅니다. 쓰지 않는 라이브러리 · 편집 화면에만 쓰는 코드는 이 화면에서 빼 주세요.`
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { LAZY_FILE_MARK, isLazyBundleFile, screenSizeIssues, screenSizes };
|
package/es/rules/types.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ export interface RulesSpec {
|
|
|
41
41
|
maxEntries: number;
|
|
42
42
|
warnRatio: number;
|
|
43
43
|
maxImageBytes: number;
|
|
44
|
+
/** 화면(HTML) 하나를 열 때 받는 JS · CSS 합계. 넘으면 limit.screen-size 경고 */
|
|
45
|
+
maxScreenBytes: number;
|
|
44
46
|
};
|
|
45
47
|
allowedExtensions: string[];
|
|
46
48
|
imageExtensions: string[];
|
|
@@ -63,6 +65,11 @@ export interface RulesSpec {
|
|
|
63
65
|
minVersions: {
|
|
64
66
|
sdk: string;
|
|
65
67
|
};
|
|
68
|
+
/** 키트 레이아웃 값 (lib/elice-content.css "레이아웃" 절과 같게). 다른 값은 layout.unknown */
|
|
69
|
+
layouts: {
|
|
70
|
+
content: string[];
|
|
71
|
+
regions: string[];
|
|
72
|
+
};
|
|
66
73
|
/**
|
|
67
74
|
* 콘텐츠 CSP가 허용하는 외부 출처 (지시어 → 출처 목록, 서버 CSP 허용 목록과 같게 유지). 검사는 여기 있는 출처를
|
|
68
75
|
* 오류(ref.external-request) 대신 경고(ref.external-font)로, `ecdk dev`는 CSP 해당 지시어에 더한다 (csp.ts)
|
|
@@ -126,6 +133,11 @@ export interface CheckOptions {
|
|
|
126
133
|
* (build.template-unknown). 없으면(서버 · 라이브러리 사용) 보지 않는다
|
|
127
134
|
*/
|
|
128
135
|
templates?: Record<string, string> | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* 프로젝트 검사일 때: 편집 화면(ecdk dev 내용 편집)이 저장한 정답 글 (.ecdk/settings.json grading, answerNeedles).
|
|
138
|
+
* 화면 코드 · JSON · 학습 참고 내용에 같은 글이 있으면 sec.answer-in-bundle 경고. 값은 메시지에 싣지 않는다
|
|
139
|
+
*/
|
|
140
|
+
answerNeedles?: string[] | undefined;
|
|
129
141
|
}
|
|
130
142
|
/** metadata.json의 build: 어떤 도구·규칙으로 만들었는지. 서버가 "오래된 규칙" 같은 안내에 쓴다 */
|
|
131
143
|
export interface BuildInfo {
|
package/es/rules.json.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const version="0.12.0";const manifest={file:"metadata.json",kinds:["material","description"],defaultKind:"material",modes:["learn","instructor","edit"],required:["learn"],kindModes:{material:["learn","instructor","edit"],description:["learn"]},graderTypes:["pattern","rubric"],commentaryFile:"commentary.txt",defaultEntry:"index.html"};const externalAllow={"style-src":[],"font-src":[]};const minVersions={sdk:"1.0.0-alpha.4"};const limits={maxZipBytes:20971520,maxUnpackedBytes:209715200,maxFiles:300,maxEntries:3000,warnRatio:0.8,maxImageBytes:1048576};const allowedExtensions=["html","htm","css","js","mjs","json","map","txt","md","csv","xml","vtt","svg","png","jpg","jpeg","gif","webp","avif","ico","bmp","mp3","wav","ogg","m4a","mp4","webm","woff","woff2","ttf","otf","glb","gltf","bin","wasm","pdf"];const imageExtensions=["png","jpg","jpeg","gif","webp","avif","bmp","svg"];const excluded={secret:{level:"error",files:[".env",".env.*","elice.config.*","grading.json","answers.*","*.pem","*.key"],dirs:[]},dev:{level:"error",files:[],dirs:[".git","node_modules",".ecdk"]},junk:{level:"warn",files:[".DS_Store","Thumbs.db","desktop.ini"],dirs:["__MACOSX"]}};const forbiddenApis=[{id:"api.parent-access",pattern:"\\bwindow\\.(?:top|parent)\\b|\\b(?:top|parent)\\.(?:document|location)\\b",title:"부모 창 직접 접근 (다른 출처라 막힘, SDK 사용)"},{id:"api.cookie",pattern:"\\bdocument\\.cookie\\b",title:"쿠키 사용 (이 브라우저에만 남고 학습 기록이 아님, 남길 입력값은 SDK로 저장)"},{id:"api.storage",pattern:"\\b(?:localStorage|sessionStorage|indexedDB)\\b",title:"브라우저 저장소 사용 (이 브라우저 · 기기에만 남고 학습 기록이 아님, 남길 입력값은 SDK로 저장)"},{id:"api.eval",pattern:"\\beval\\s*\\(|\\bnew\\s+Function\\s*\\(|\\bset(?:Timeout|Interval)\\s*\\(\\s*[\"'`]",title:"eval · new Function · 문자열 setTimeout 사용"},{id:"api.dialog",pattern:"\\b(?:alert|confirm|prompt)\\s*\\(",title:"alert · confirm · prompt 사용 (sandbox에서 막힘, 화면 안 메시지로)"},{id:"api.window-open",pattern:"\\bwindow\\.open\\s*\\(",title:"새 창 열기 (sandbox에서 막힘)"},{id:"api.external-send",pattern:"\\b(?:fetch|sendBeacon|EventSource|WebSocket)\\s*\\(\\s*['\"`](?:https?|wss?):\\/\\/|\\.open\\(\\s*['\"`][A-Za-z]+['\"`]\\s*,\\s*['\"`]https?:\\/\\/",title:"외부 주소로 요청을 보냄 (학생 정보 유출 위험)"},{id:"sec.html-injection",pattern:"\\.(?:inner|outer)HTML\\s*\\+?=(?!=)(?!\\s*(?:'[^'\\n]*'|\"[^\"\\n]*\"|`[^`$\\n]*`)\\s*(?:[;,)}\\n]|$))|\\.insertAdjacentHTML\\s*\\(|\\bdocument\\.write(?:ln)?\\s*\\(|\\bdangerouslySetInnerHTML\\b",title:"HTML 문자열을 그대로 넣음 (XSS 위험, textContent나 이스케이프 사용)"},{id:"sec.redirect",pattern:"\\blocation(?:\\.href)?\\s*=(?!=)(?!\\s*[\"'`][^\"'`$]*[\"'`])|\\blocation\\.(?:replace|assign)\\s*\\((?!\\s*[\"'`][^\"'`$]*[\"'`]\\s*\\))",title:"주소를 값으로 바꿈 (열린 리디렉션 · javascript: XSS 위험)"},{id:"sec.postmessage-wildcard",pattern:"\\.postMessage\\s*\\([^;]*?,\\s*[\"'`]\\*[\"'`]",title:"postMessage 대상이 * (아무 창이나 받을 수 있음)"},{id:"sandbox.fetch-local",pattern:"\\bfetch\\(\\s*(['\"`])(?![a-z][a-z0-9+.-]*:|//)[^'\"`]*(?<!\\.json)\\1|\\bimport\\(\\s*(?!['\"`])[A-Za-z_$]|\\bnew\\s+(?:Shared)?Worker\\(\\s*['\"`](?![a-z][a-z0-9+.-]*:|//)",title:"zip 안 파일을 fetch · 변수 import() · Worker로 읽음 (콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없으면 CORS로 막힘)"}];const secretPatterns=[{source:"elice-hardcoded-private-key · detected-private-key · detected-pgp-private-key-block",title:"개인키",pattern:"-----BEGIN[ A-Z0-9_-]*PRIVATE KEY(?: BLOCK)?-----"},{source:"elice-hardcoded-secret",title:"하드코딩된 비밀 값",pattern:"(?:secret|token|api[_-]?key|access[_-]?key|password|passwd)\\s*[:=]\\s*[\"'][A-Za-z0-9_\\-/+]{16,}[\"']",flags:"i",not:"os\\.environ|getenv|process\\.env|dotenv|\\$\\{|<[a-z_]+>|example|dummy|placeholder|changeme|xxxx|your[_-]"},{source:"detected-aws-access-key-id-value",title:"AWS 액세스 키",pattern:"\\b(?:A3T[A-Z0-9]|AKIA|AGPA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}\\b",not:"example|sample|test|fake"},{source:"detected-aws-secret-access-key",title:"AWS 비밀 키",pattern:"[\"'`]?aws_?\\w*secret_?\\w*[\"'`]?\\s{0,50}(?::|=>|=)\\s{0,50}[\"'`]?[A-Za-z0-9/+=]{40}",flags:"i",not:"example|sample|test|fake|xxxxxx"},{source:"detected-aws-session-token",title:"AWS 세션 토큰",pattern:"AWS_SESSION_TOKEN\\s*(?::|=>|=)\\s*[A-Za-z0-9/+=]{16,}",flags:"i",not:"example|sample|test|fake"},{source:"detected-aws-appsync-graphql-key",title:"AWS AppSync 키",pattern:"da2-[a-z0-9]{26}"},{source:"detected-amazon-mws-auth-token",title:"Amazon MWS 토큰",pattern:"amzn\\.mws\\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"},{source:"detected-artifactory-token",title:"Artifactory 토큰",pattern:"\\bAKC[a-zA-Z0-9]{10,}\\n",not:"sha(?:128|256|512)"},{source:"detected-artifactory-password",title:"Artifactory 비밀번호",pattern:"[Aa][Rr][Tt][Ii][-_]?[Ff][Aa][Cc][Tt][Oo][Rr][Yy].*\\bAP[\\dA-F][a-zA-Z0-9]{8,}|\\bAP[\\dA-F][a-zA-Z0-9]{8,}.*[Aa][Rr][Tt][Ii][-_]?[Ff][Aa][Cc][Tt][Oo][Rr][Yy]",not:"sha(?:1|2|3|118|256|512)"},{source:"detected-bcrypt-hash",title:"bcrypt 해시",pattern:"\\$2[aby]?\\$\\d+\\$[./A-Za-z0-9]{53}"},{source:"detected-codeclimate",title:"Code Climate 토큰",pattern:"codeclima.{0,50}[\"'`]?[0-9a-f]{64}",flags:"i"},{source:"detected-etc-shadow",title:"/etc/shadow 내용",pattern:"^\\s*root:[x!*]*:\\d*:\\d*",flags:"m"},{source:"detected-facebook-access-token",title:"Facebook 액세스 토큰",pattern:"EAACEdEose0cBA[0-9A-Za-z]+|EAAAACZAVC6ygB[0-9A-Za-z]+|EAAAAZAw4[0-9A-Za-z]+"},{source:"detected-facebook-oauth",title:"Facebook OAuth 비밀",pattern:"[fF][aA][cC][eE][bB][oO][oO][kK].*[tT][oO][kK][eE][nN].*[\"'`]?[0-9a-f]{32}"},{source:"detected-google-gcm-service-account",title:"Google 서비스 계정 키",pattern:"[\"'`]?type[\"'`]?\\s{0,50}(?::|=>|=)\\s{0,50}[\"'`]?service_account"},{source:"detected-google-oauth-access-token",title:"Google OAuth 토큰",pattern:"ya29\\.[0-9A-Za-z_-]+"},{source:"detected-heroku-api-key",title:"Heroku API 키",pattern:"[hH][eE][rR][oO][kK][uU].*[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}"},{source:"detected-hockeyapp",title:"HockeyApp 토큰",pattern:"hockey.{0,50}[\"'`]?[0-9a-f]{32}",flags:"i"},{source:"detected-mailchimp-api-key",title:"Mailchimp API 키",pattern:"[0-9a-f]{32}-us\\d{1,2}"},{source:"detected-mailgun-api-key",title:"Mailgun API 키",pattern:"key-[0-9a-zA-Z]{32}"},{source:"detected-onfido-live-api-token",title:"Onfido API 토큰",pattern:"api_live(?:_[a-zA-Z]{2})?\\.[a-zA-Z0-9_-]{11}\\.[a-zA-Z0-9_-]{32}"},{source:"detected-outlook-team",title:"Outlook 웹훅",pattern:"https://outlook\\.office\\.com/webhook/[0-9a-f-]{36}"},{source:"detected-paypal-braintree-access-token",title:"PayPal Braintree 토큰",pattern:"access_token\\$production\\$[0-9a-z]{16}\\$[0-9a-z]{32}"},{source:"detected-picatic-api-key",title:"Picatic API 키",pattern:"sk_live_[0-9a-z]{32}"},{source:"detected-sauce-token",title:"Sauce Labs 토큰",pattern:"sauce.{0,50}[\"'`]?[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}",flags:"i"},{source:"detected-slack-token",title:"Slack 토큰",pattern:"xox[pboa]-\\d{12}-\\d{12}-\\d{12}-[a-z0-9]{32}|xox.-\\d{12}-\\d{12}-[0-9a-zA-Z]{24}"},{source:"detected-slack-webhook",title:"Slack 웹훅",pattern:"https://hooks\\.slack\\.com/services/T[a-zA-Z0-9_]{8,10}/B[a-zA-Z0-9_]{8,10}/[a-zA-Z0-9_]{24}",not:"T00000000/B00000000/X{24}"},{source:"detected-sonarqube-docs-api-key",title:"SonarQube 토큰",pattern:"sonar[a-z0-9_.-]{0,30}(?:token|key|login|password|pass|secret|auth)?\\s*[:=]\\s*\\\\?[\"'`]?[0-9a-f]{40}\\b",flags:"i"},{source:"detected-square-access-token",title:"Square 액세스 토큰",pattern:"sq0atp-[0-9A-Za-z_-]{22}"},{source:"detected-square-oauth-secret",title:"Square OAuth 비밀",pattern:"sq0csp-[0-9A-Za-z\\\\_-]{43}"},{source:"detected-ssh-password",title:"sshpass 비밀번호",pattern:"sshpass[ ]-p\\s*['\"]"},{source:"detected-stripe-api-key",title:"Stripe API 키",pattern:"sk_live_[0-9a-zA-Z]{24}"},{source:"detected-stripe-restricted-api-key",title:"Stripe 제한 키",pattern:"rk_live_[0-9a-zA-Z]{24}"},{source:"detected-telegram-bot-api-key",title:"Telegram 봇 토큰",pattern:"\\d+:AA[0-9A-Za-z_-]{33}",not:"go\\.mod|v\\d+\\.\\d+\\.\\d+"},{source:"detected-twilio-api-key",title:"Twilio API 키",pattern:"SK[0-9a-fA-F]{32}"},{source:"detected-username-and-password-in-uri",title:"주소에 들어 있는 아이디 · 비밀번호",pattern:"[A-Za-z0-9+.-]*(?:http|sql|ftp|smtp)[A-Za-z0-9+.-]*://\\{?[A-Za-z][A-Za-z0-9_-]{5,31}\\}?:(?=[^\\s@/]*\\d)(?=[^\\s@/]*[a-z])(?=[^\\s@/]*[A-Z])(?=[^\\s@/]*[!-.:-?\\[-`{-~])[^\\s@/]{6,32}@"}];const rules=[{id:"manifest.missing",level:"error",scope:"server",title:"metadata.json 없음"},{id:"manifest.invalid",level:"error",scope:"server",title:"metadata.json 형식 오류"},{id:"manifest.entry-missing",level:"error",scope:"server",title:"metadata.json에 적은 파일(진입 파일 · 학습 참고 내용)이 없음"},{id:"manifest.commentary-missing",level:"error",scope:"server",title:"학습 참고 내용 파일(commentary.txt) 없음 (LXP 업로드가 거절함)"},{id:"manifest.grading-types",level:"warn",scope:"server",title:"쓰지 않는 gradingTypes (완료 정책은 LXP 설정, 채점 방식은 편집 화면)"},{id:"manifest.completion-policies-ignored",level:"warn",scope:"client",title:"쓰지 않는 completionPolicies · 완료 정책 화면(screens.completionPolicy) (완료 정책은 LXP 설정, build가 zip에서 뺌)"},{id:"entry.missing",level:"error",scope:"server",title:"학생 화면 진입 파일 없음"},{id:"entry.nested",level:"error",scope:"server",title:"폴더째 묶은 zip (metadata.json이 최상위에 없음)"},{id:"input.not-zip",level:"error",scope:"server",title:"zip이 아닌 업로드 (HTML 파일 하나 등)"},{id:"limit.zip-size",level:"error",scope:"server",title:"zip 크기 한도 초과"},{id:"limit.file-count",level:"error",scope:"server",title:"파일 개수 한도 초과"},{id:"limit.unpacked-size",level:"error",scope:"server",title:"풀면 너무 큰 zip (압축 폭탄 의심)"},{id:"limit.near",level:"warn",scope:"client",title:"한도에 가까움"},{id:"path.unsafe",level:"error",scope:"server",title:"안전하지 않은 경로 (절대경로, .., 역슬래시, 정규화 안 됨)"},{id:"path.case-collision",level:"error",scope:"server",title:"대소문자만 다른 경로"},{id:"path.non-ascii",level:"warn",scope:"client",title:"공백·한글 등 ASCII 밖 문자가 든 경로"},{id:"file.extension",level:"error",scope:"server",title:"허용하지 않는 확장자"},{id:"file.secret",level:"error",scope:"server",title:"정답·비밀 파일 포함"},{id:"file.dev",level:"error",scope:"server",title:"개발용 폴더 포함"},{id:"file.junk",level:"warn",scope:"server",title:"운영체제가 만든 불필요한 파일"},{id:"file.large-image",level:"warn",scope:"client",title:"1MB 넘는 이미지"},{id:"file.encoding",level:"error",scope:"client",title:"UTF-8이 아닌 텍스트 파일 (한글이 깨짐)"},{id:"file.bom",level:"warn",scope:"client",title:"학습 참고 내용 맨 앞의 BOM (보이지 않는 글자)"},{id:"content.answer-key",level:"warn",scope:"client",title:"학생에게 내려가는 JSON에 정답처럼 보이는 키"},{id:"grading.no-submit",level:"warn",scope:"client",title:"편집 화면이 채점 설정을 저장하는데 화면 코드에 제출이 없음"},{id:"edit.no-save",level:"warn",scope:"client",title:"편집 화면인데 저장이 없음"},{id:"project.legacy-file",level:"warn",scope:"client",title:"더 쓰지 않는 프로젝트 파일(elice.config.json · content.json · grading.json)이 남아 있음 (프로젝트 검사만, ADR 0011)"},{id:"build.template-unknown",level:"warn",scope:"client",title:"metadata.json build.template이 이 ecdk가 모르는 템플릿이거나 더 새 템플릿 버전"},{id:"ref.missing",level:"error",scope:"client",title:"참조한 파일이 없음"},{id:"ref.case-mismatch",level:"error",scope:"client",title:"참조 경로의 대소문자가 실제 파일과 다름"},{id:"ref.root-absolute",level:"error",scope:"client",title:"/로 시작하는 경로 · 자기 폴더가 아닌 <base href> (배포 주소 /s/{서명}/ 아래에서 깨짐)"},{id:"ref.external-script",level:"error",scope:"client",title:"외부 스크립트 (zip 안에 넣고 상대경로로)"},{id:"ref.external-request",level:"error",scope:"client",title:"외부 리소스 요청 (이미지 · 글꼴 · 영상 · CSS, 콘텐츠 CSP가 막음: zip 안에 넣기)"},{id:"ref.external-font",level:"warn",scope:"client",title:"허용 목록(externalAllow)의 외부 글꼴 (망분리 기관에서는 받지 못해 기본 글꼴로 보일 수 있음)"},{id:"ref.insecure",level:"error",scope:"client",title:"http:// 외부 리소스 (https 페이지 · 콘텐츠 CSP가 막음)"},{id:"ref.vendor-external-url",level:"warn",scope:"client",title:"라이브러리 파일 안의 외부 주소 (실행 중 외부를 부르면 콘텐츠 CSP가 막음, ecdk dev 로그 확인)"},{id:"ref.script-not-public",level:"error",scope:"client",title:"type=\"module\" 없는 <script src>가 public/ 밖 파일 (프로젝트 검사만. build가 묶지 않고 zip에도 넣지 않음, type=\"module\"을 붙이거나 public/으로)"},{id:"sandbox.module-src",level:"warn",scope:"client",title:"모듈 스크립트 파일(<script type=\"module\" src>): 콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없는 LXP에서는 CORS로 막혀 화면이 뜨지 않음 (ecdk build가 HTML 안에 묶음)"},{id:"sandbox.fetch-local",level:"warn",scope:"client",title:"zip 안 파일을 fetch · 변수 import() · Worker로 읽음: 콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없는 LXP에서는 CORS로 막힘 (JSON fetch · 문자열 import()는 ecdk build가 처리)"},{id:"html.img-alt",level:"warn",scope:"client",title:"대체 텍스트 없는 이미지"},{id:"html.iframe",level:"error",scope:"client",title:"src로 띄우는 iframe · frame, object · embed (콘텐츠 CSP가 막음, 영상은 Elice 비디오 자료로, srcdoc 미리보기는 통과)"},{id:"html.form",level:"warn",scope:"client",title:"form 제출 (sandbox · CSP form-action이 막음, 버튼 click으로 처리)"},{id:"api.external-send",level:"error",scope:"client",title:"외부 주소로 요청 보냄"},{id:"api.parent-access",level:"warn",scope:"client",title:"부모 창 직접 접근"},{id:"api.cookie",level:"warn",scope:"client",title:"쿠키 사용 (학습 기록이 아님)"},{id:"api.storage",level:"warn",scope:"client",title:"브라우저 저장소 사용 (학습 기록이 아님)"},{id:"api.eval",level:"warn",scope:"client",title:"eval · new Function 사용"},{id:"api.dialog",level:"error",scope:"client",title:"alert · confirm · prompt 사용"},{id:"api.window-open",level:"error",scope:"client",title:"새 창 열기"},{id:"sec.secret",level:"error",scope:"server",title:"비밀 값 (키 · 토큰 · 비밀번호)"},{id:"sec.html-injection",level:"warn",scope:"client",title:"HTML 문자열 삽입"},{id:"sec.redirect",level:"warn",scope:"client",title:"주소를 값으로 바꿈"},{id:"sec.postmessage-wildcard",level:"warn",scope:"client",title:"postMessage 대상 *"},{id:"sdk.outdated",level:"error",scope:"client",title:"SDK가 최소 버전보다 낮음 (metadata.json build.sdk < rules.json minVersions.sdk. alpha.3 이하는 LXP 편집 화면 저장(초안) 실패, npm update @eliceio/cdk)"},{id:"sdk.lib-copy",level:"error",scope:"client",title:"SDK 복사본 lib/cdk.js (zip에 넣지 않음, 프로젝트 검사만. SDK는 package.json 의존성 @eliceio/cdk를 build가 번들로 묶음)"}];var rulesJson = {version:version,manifest:manifest,externalAllow:externalAllow,minVersions:minVersions,limits:limits,allowedExtensions:allowedExtensions,imageExtensions:imageExtensions,excluded:excluded,forbiddenApis:forbiddenApis,secretPatterns:secretPatterns,rules:rules};
|
|
1
|
+
const version="0.17.0";const manifest={file:"metadata.json",kinds:["material","description"],defaultKind:"material",modes:["learn","instructor","edit"],required:["learn"],kindModes:{material:["learn","instructor","edit"],description:["learn"]},graderTypes:["pattern","partial_pattern","rubric"],commentaryFile:"commentary.txt",defaultEntry:"index.html"};const externalAllow={"style-src":[],"font-src":[]};const minVersions={sdk:"1.0.0-alpha.4"};const layouts={content:["single","split","stage","media"],regions:["main","aside","stage","controls","readout","actions"]};const limits={maxZipBytes:20971520,maxUnpackedBytes:209715200,maxFiles:300,maxEntries:3000,warnRatio:0.8,maxImageBytes:1048576,maxScreenBytes:1572864};const allowedExtensions=["html","htm","css","js","mjs","json","map","txt","md","csv","xml","vtt","svg","png","jpg","jpeg","gif","webp","avif","ico","bmp","mp3","wav","ogg","m4a","mp4","webm","woff","woff2","ttf","otf","glb","gltf","bin","wasm","pdf"];const imageExtensions=["png","jpg","jpeg","gif","webp","avif","bmp","svg"];const excluded={secret:{level:"error",files:[".env",".env.*","elice.config.*","grading.json","answers.*","*.pem","*.key"],dirs:[]},dev:{level:"error",files:[],dirs:[".git","node_modules",".ecdk"]},junk:{level:"warn",files:[".DS_Store","Thumbs.db","desktop.ini"],dirs:["__MACOSX"]}};const forbiddenApis=[{id:"api.parent-access",pattern:"\\bwindow\\.(?:top|parent)\\b|\\b(?:top|parent)\\.(?:document|location)\\b",title:"부모 창 직접 접근 (다른 출처라 막힘, SDK 사용)"},{id:"api.cookie",pattern:"\\bdocument\\.cookie\\b",title:"쿠키 사용 (이 브라우저에만 남고 학습 기록이 아님, 남길 입력값은 SDK로 저장)"},{id:"api.storage",pattern:"\\b(?:localStorage|sessionStorage|indexedDB)\\b",title:"브라우저 저장소 사용 (이 브라우저 · 기기에만 남고 학습 기록이 아님, 남길 입력값은 SDK로 저장)"},{id:"api.eval",pattern:"\\beval\\s*\\(|\\bnew\\s+Function\\s*\\(|\\bset(?:Timeout|Interval)\\s*\\(\\s*[\"'`]",title:"eval · new Function · 문자열 setTimeout 사용"},{id:"api.dialog",pattern:"\\b(?:alert|confirm|prompt)\\s*\\(",title:"alert · confirm · prompt 사용 (sandbox에서 막힘, 화면 안 메시지로)"},{id:"api.window-open",pattern:"\\bwindow\\.open\\s*\\(",title:"새 창 열기 (sandbox에서 막힘)"},{id:"api.external-send",pattern:"\\b(?:fetch|sendBeacon|EventSource|WebSocket)\\s*\\(\\s*['\"`](?:https?|wss?):\\/\\/|\\.open\\(\\s*['\"`][A-Za-z]+['\"`]\\s*,\\s*['\"`]https?:\\/\\/",title:"외부 주소로 요청을 보냄 (학생 정보 유출 위험)"},{id:"sec.html-injection",pattern:"\\.(?:inner|outer)HTML\\s*\\+?=(?!=)(?!\\s*(?:'[^'\\n]*'|\"[^\"\\n]*\"|`[^`$\\n]*`)\\s*(?:[;,)}\\n]|$))|\\.insertAdjacentHTML\\s*\\(|\\bdocument\\.write(?:ln)?\\s*\\(|\\bdangerouslySetInnerHTML\\b",title:"HTML 문자열을 그대로 넣음 (XSS 위험, textContent나 이스케이프 사용)"},{id:"sec.redirect",pattern:"\\blocation(?:\\.href)?\\s*=(?!=)(?!\\s*[\"'`][^\"'`$]*[\"'`])|\\blocation\\.(?:replace|assign)\\s*\\((?!\\s*[\"'`][^\"'`$]*[\"'`]\\s*\\))",title:"주소를 값으로 바꿈 (열린 리디렉션 · javascript: XSS 위험)"},{id:"sec.postmessage-wildcard",pattern:"\\.postMessage\\s*\\([^;]*?,\\s*[\"'`]\\*[\"'`]",title:"postMessage 대상이 * (아무 창이나 받을 수 있음)"},{id:"sandbox.fetch-local",pattern:"\\bfetch\\(\\s*(['\"`])(?![a-z][a-z0-9+.-]*:|//)[^'\"`]*(?<!\\.json)\\1|\\bimport\\(\\s*(?!['\"`])[A-Za-z_$]|\\bnew\\s+(?:Shared)?Worker\\(\\s*['\"`](?![a-z][a-z0-9+.-]*:|//)",title:"zip 안 파일을 fetch · 변수 import() · Worker로 읽음 (콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없으면 CORS로 막힘)"}];const secretPatterns=[{source:"elice-hardcoded-private-key · detected-private-key · detected-pgp-private-key-block",title:"개인키",pattern:"-----BEGIN[ A-Z0-9_-]*PRIVATE KEY(?: BLOCK)?-----"},{source:"elice-hardcoded-secret",title:"하드코딩된 비밀 값",pattern:"(?:secret|token|api[_-]?key|access[_-]?key|password|passwd)\\s*[:=]\\s*[\"'][A-Za-z0-9_\\-/+]{16,}[\"']",flags:"i",not:"os\\.environ|getenv|process\\.env|dotenv|\\$\\{|<[a-z_]+>|example|dummy|placeholder|changeme|xxxx|your[_-]"},{source:"detected-aws-access-key-id-value",title:"AWS 액세스 키",pattern:"\\b(?:A3T[A-Z0-9]|AKIA|AGPA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}\\b",not:"example|sample|test|fake"},{source:"detected-aws-secret-access-key",title:"AWS 비밀 키",pattern:"[\"'`]?aws_?\\w*secret_?\\w*[\"'`]?\\s{0,50}(?::|=>|=)\\s{0,50}[\"'`]?[A-Za-z0-9/+=]{40}",flags:"i",not:"example|sample|test|fake|xxxxxx"},{source:"detected-aws-session-token",title:"AWS 세션 토큰",pattern:"AWS_SESSION_TOKEN\\s*(?::|=>|=)\\s*[A-Za-z0-9/+=]{16,}",flags:"i",not:"example|sample|test|fake"},{source:"detected-aws-appsync-graphql-key",title:"AWS AppSync 키",pattern:"da2-[a-z0-9]{26}"},{source:"detected-amazon-mws-auth-token",title:"Amazon MWS 토큰",pattern:"amzn\\.mws\\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"},{source:"detected-artifactory-token",title:"Artifactory 토큰",pattern:"\\bAKC[a-zA-Z0-9]{10,}\\n",not:"sha(?:128|256|512)"},{source:"detected-artifactory-password",title:"Artifactory 비밀번호",pattern:"[Aa][Rr][Tt][Ii][-_]?[Ff][Aa][Cc][Tt][Oo][Rr][Yy].*\\bAP[\\dA-F][a-zA-Z0-9]{8,}|\\bAP[\\dA-F][a-zA-Z0-9]{8,}.*[Aa][Rr][Tt][Ii][-_]?[Ff][Aa][Cc][Tt][Oo][Rr][Yy]",not:"sha(?:1|2|3|118|256|512)"},{source:"detected-bcrypt-hash",title:"bcrypt 해시",pattern:"\\$2[aby]?\\$\\d+\\$[./A-Za-z0-9]{53}"},{source:"detected-codeclimate",title:"Code Climate 토큰",pattern:"codeclima.{0,50}[\"'`]?[0-9a-f]{64}",flags:"i"},{source:"detected-etc-shadow",title:"/etc/shadow 내용",pattern:"^\\s*root:[x!*]*:\\d*:\\d*",flags:"m"},{source:"detected-facebook-access-token",title:"Facebook 액세스 토큰",pattern:"EAACEdEose0cBA[0-9A-Za-z]+|EAAAACZAVC6ygB[0-9A-Za-z]+|EAAAAZAw4[0-9A-Za-z]+"},{source:"detected-facebook-oauth",title:"Facebook OAuth 비밀",pattern:"[fF][aA][cC][eE][bB][oO][oO][kK].*[tT][oO][kK][eE][nN].*[\"'`]?[0-9a-f]{32}"},{source:"detected-google-gcm-service-account",title:"Google 서비스 계정 키",pattern:"[\"'`]?type[\"'`]?\\s{0,50}(?::|=>|=)\\s{0,50}[\"'`]?service_account"},{source:"detected-google-oauth-access-token",title:"Google OAuth 토큰",pattern:"ya29\\.[0-9A-Za-z_-]+"},{source:"detected-heroku-api-key",title:"Heroku API 키",pattern:"[hH][eE][rR][oO][kK][uU].*[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}"},{source:"detected-hockeyapp",title:"HockeyApp 토큰",pattern:"hockey.{0,50}[\"'`]?[0-9a-f]{32}",flags:"i"},{source:"detected-mailchimp-api-key",title:"Mailchimp API 키",pattern:"[0-9a-f]{32}-us\\d{1,2}"},{source:"detected-mailgun-api-key",title:"Mailgun API 키",pattern:"key-[0-9a-zA-Z]{32}"},{source:"detected-onfido-live-api-token",title:"Onfido API 토큰",pattern:"api_live(?:_[a-zA-Z]{2})?\\.[a-zA-Z0-9_-]{11}\\.[a-zA-Z0-9_-]{32}"},{source:"detected-outlook-team",title:"Outlook 웹훅",pattern:"https://outlook\\.office\\.com/webhook/[0-9a-f-]{36}"},{source:"detected-paypal-braintree-access-token",title:"PayPal Braintree 토큰",pattern:"access_token\\$production\\$[0-9a-z]{16}\\$[0-9a-z]{32}"},{source:"detected-picatic-api-key",title:"Picatic API 키",pattern:"sk_live_[0-9a-z]{32}"},{source:"detected-sauce-token",title:"Sauce Labs 토큰",pattern:"sauce.{0,50}[\"'`]?[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}",flags:"i"},{source:"detected-slack-token",title:"Slack 토큰",pattern:"xox[pboa]-\\d{12}-\\d{12}-\\d{12}-[a-z0-9]{32}|xox.-\\d{12}-\\d{12}-[0-9a-zA-Z]{24}"},{source:"detected-slack-webhook",title:"Slack 웹훅",pattern:"https://hooks\\.slack\\.com/services/T[a-zA-Z0-9_]{8,10}/B[a-zA-Z0-9_]{8,10}/[a-zA-Z0-9_]{24}",not:"T00000000/B00000000/X{24}"},{source:"detected-sonarqube-docs-api-key",title:"SonarQube 토큰",pattern:"sonar[a-z0-9_.-]{0,30}(?:token|key|login|password|pass|secret|auth)?\\s*[:=]\\s*\\\\?[\"'`]?[0-9a-f]{40}\\b",flags:"i"},{source:"detected-square-access-token",title:"Square 액세스 토큰",pattern:"sq0atp-[0-9A-Za-z_-]{22}"},{source:"detected-square-oauth-secret",title:"Square OAuth 비밀",pattern:"sq0csp-[0-9A-Za-z\\\\_-]{43}"},{source:"detected-ssh-password",title:"sshpass 비밀번호",pattern:"sshpass[ ]-p\\s*['\"]"},{source:"detected-stripe-api-key",title:"Stripe API 키",pattern:"sk_live_[0-9a-zA-Z]{24}"},{source:"detected-stripe-restricted-api-key",title:"Stripe 제한 키",pattern:"rk_live_[0-9a-zA-Z]{24}"},{source:"detected-telegram-bot-api-key",title:"Telegram 봇 토큰",pattern:"\\d+:AA[0-9A-Za-z_-]{33}",not:"go\\.mod|v\\d+\\.\\d+\\.\\d+"},{source:"detected-twilio-api-key",title:"Twilio API 키",pattern:"SK[0-9a-fA-F]{32}"},{source:"detected-username-and-password-in-uri",title:"주소에 들어 있는 아이디 · 비밀번호",pattern:"[A-Za-z0-9+.-]*(?:http|sql|ftp|smtp)[A-Za-z0-9+.-]*://\\{?[A-Za-z][A-Za-z0-9_-]{5,31}\\}?:(?=[^\\s@/]*\\d)(?=[^\\s@/]*[a-z])(?=[^\\s@/]*[A-Z])(?=[^\\s@/]*[!-.:-?\\[-`{-~])[^\\s@/]{6,32}@"}];const rules=[{id:"manifest.missing",level:"error",scope:"server",title:"metadata.json 없음"},{id:"manifest.invalid",level:"error",scope:"server",title:"metadata.json 형식 오류"},{id:"manifest.entry-missing",level:"error",scope:"server",title:"metadata.json에 적은 파일(진입 파일 · 학습 참고 내용)이 없음"},{id:"manifest.commentary-missing",level:"error",scope:"server",title:"학습 참고 내용 파일(commentary.txt) 없음 (LXP 업로드가 거절함)"},{id:"manifest.grading-types",level:"warn",scope:"server",title:"쓰지 않는 gradingTypes (완료 정책은 LXP 설정, 채점 방식은 편집 화면)"},{id:"manifest.completion-policies-ignored",level:"warn",scope:"client",title:"쓰지 않는 completionPolicies · 완료 정책 화면(screens.completionPolicy) (완료 정책은 LXP 설정, build가 zip에서 뺌)"},{id:"entry.missing",level:"error",scope:"server",title:"학생 화면 진입 파일 없음"},{id:"entry.nested",level:"error",scope:"server",title:"폴더째 묶은 zip (metadata.json이 최상위에 없음)"},{id:"input.not-zip",level:"error",scope:"server",title:"zip이 아닌 업로드 (HTML 파일 하나 등)"},{id:"limit.zip-size",level:"error",scope:"server",title:"zip 크기 한도 초과"},{id:"limit.file-count",level:"error",scope:"server",title:"파일 개수 한도 초과"},{id:"limit.unpacked-size",level:"error",scope:"server",title:"풀면 너무 큰 zip (압축 폭탄 의심)"},{id:"limit.near",level:"warn",scope:"client",title:"한도에 가까움"},{id:"limit.screen-size",level:"warn",scope:"client",title:"화면 하나를 열 때 받는 JS · CSS가 큼 (기준 limits.maxScreenBytes, 큰 라이브러리는 import()로)"},{id:"path.unsafe",level:"error",scope:"server",title:"안전하지 않은 경로 (절대경로, .., 역슬래시, 정규화 안 됨)"},{id:"path.case-collision",level:"error",scope:"server",title:"대소문자만 다른 경로"},{id:"path.non-ascii",level:"warn",scope:"client",title:"공백·한글 등 ASCII 밖 문자가 든 경로"},{id:"file.extension",level:"error",scope:"server",title:"허용하지 않는 확장자"},{id:"file.secret",level:"error",scope:"server",title:"정답·비밀 파일 포함"},{id:"file.dev",level:"error",scope:"server",title:"개발용 폴더 포함"},{id:"file.junk",level:"warn",scope:"server",title:"운영체제가 만든 불필요한 파일"},{id:"file.large-image",level:"warn",scope:"client",title:"1MB 넘는 이미지"},{id:"file.encoding",level:"error",scope:"client",title:"UTF-8이 아닌 텍스트 파일 (한글이 깨짐)"},{id:"file.bom",level:"warn",scope:"client",title:"학습 참고 내용 맨 앞의 BOM (보이지 않는 글자)"},{id:"content.answer-key",level:"warn",scope:"client",title:"학생에게 내려가는 JSON에 정답처럼 보이는 키"},{id:"grading.no-submit",level:"warn",scope:"client",title:"편집 화면이 채점 설정을 저장하는데 화면 코드에 제출이 없음"},{id:"edit.no-save",level:"warn",scope:"client",title:"편집 화면인데 저장이 없음"},{id:"project.legacy-file",level:"warn",scope:"client",title:"더 쓰지 않는 프로젝트 파일(elice.config.json · content.json · grading.json)이 남아 있음 (프로젝트 검사만, ADR 0011)"},{id:"build.template-unknown",level:"warn",scope:"client",title:"metadata.json build.template이 이 ecdk가 모르는 템플릿이거나 더 새 템플릿 버전"},{id:"layout.unknown",level:"warn",scope:"client",title:"data-ec-layout · data-ec-region에 키트가 모르는 값 (single · split · stage · media, main · aside · stage · controls · readout · actions)"},{id:"layout.own-step-nav",level:"warn",scope:"client",title:"화면 코드가 이전 · 다음 버튼을 직접 그림 (LXP 이전 · 다음 막대와 헷갈림, 키트 app.useStepper)"},{id:"ref.missing",level:"error",scope:"client",title:"참조한 파일이 없음"},{id:"ref.case-mismatch",level:"error",scope:"client",title:"참조 경로의 대소문자가 실제 파일과 다름"},{id:"ref.root-absolute",level:"error",scope:"client",title:"/로 시작하는 경로 · 자기 폴더가 아닌 <base href> (배포 주소 /s/{서명}/ 아래에서 깨짐)"},{id:"ref.external-script",level:"error",scope:"client",title:"외부 스크립트 (zip 안에 넣고 상대경로로)"},{id:"ref.external-request",level:"error",scope:"client",title:"외부 리소스 요청 (이미지 · 글꼴 · 영상 · CSS, 콘텐츠 CSP가 막음: zip 안에 넣기)"},{id:"ref.external-font",level:"warn",scope:"client",title:"허용 목록(externalAllow)의 외부 글꼴 (망분리 기관에서는 받지 못해 기본 글꼴로 보일 수 있음)"},{id:"ref.insecure",level:"error",scope:"client",title:"http:// 외부 리소스 (https 페이지 · 콘텐츠 CSP가 막음)"},{id:"ref.vendor-external-url",level:"warn",scope:"client",title:"라이브러리 파일 안의 외부 주소 (실행 중 외부를 부르면 콘텐츠 CSP가 막음, ecdk dev 로그 확인)"},{id:"ref.script-not-public",level:"error",scope:"client",title:"type=\"module\" 없는 <script src>가 public/ 밖 파일 (프로젝트 검사만. build가 묶지 않고 zip에도 넣지 않음, type=\"module\"을 붙이거나 public/으로)"},{id:"sandbox.module-src",level:"warn",scope:"client",title:"모듈 스크립트 파일(<script type=\"module\" src>): 콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없는 LXP에서는 CORS로 막혀 화면이 뜨지 않음 (ecdk build가 HTML 안에 묶음)"},{id:"sandbox.fetch-local",level:"warn",scope:"client",title:"zip 안 파일을 fetch · 변수 import() · Worker로 읽음: 콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없는 LXP에서는 CORS로 막힘 (JSON fetch · 문자열 import()는 ecdk build가 처리)"},{id:"html.img-alt",level:"warn",scope:"client",title:"대체 텍스트 없는 이미지"},{id:"html.iframe",level:"error",scope:"client",title:"src로 띄우는 iframe · frame, object · embed (콘텐츠 CSP가 막음, 영상은 Elice 비디오 자료로, srcdoc 미리보기는 통과)"},{id:"html.form",level:"warn",scope:"client",title:"form 제출 (sandbox · CSP form-action이 막음, 버튼 click으로 처리)"},{id:"api.external-send",level:"error",scope:"client",title:"외부 주소로 요청 보냄"},{id:"api.parent-access",level:"warn",scope:"client",title:"부모 창 직접 접근"},{id:"api.cookie",level:"warn",scope:"client",title:"쿠키 사용 (학습 기록이 아님)"},{id:"api.storage",level:"warn",scope:"client",title:"브라우저 저장소 사용 (학습 기록이 아님)"},{id:"api.eval",level:"warn",scope:"client",title:"eval · new Function 사용"},{id:"api.dialog",level:"error",scope:"client",title:"alert · confirm · prompt 사용"},{id:"api.window-open",level:"error",scope:"client",title:"새 창 열기"},{id:"sec.secret",level:"error",scope:"server",title:"비밀 값 (키 · 토큰 · 비밀번호)"},{id:"sec.answer-in-bundle",level:"warn",scope:"client",title:"편집 화면에 저장한 정답(.ecdk/settings.json 채점 설정)과 같은 글이 zip에 들어갈 파일에 있음 (프로젝트 검사만)"},{id:"sec.html-injection",level:"warn",scope:"client",title:"HTML 문자열 삽입"},{id:"sec.redirect",level:"warn",scope:"client",title:"주소를 값으로 바꿈"},{id:"sec.postmessage-wildcard",level:"warn",scope:"client",title:"postMessage 대상 *"},{id:"sdk.outdated",level:"error",scope:"client",title:"SDK가 최소 버전보다 낮음 (metadata.json build.sdk < rules.json minVersions.sdk. alpha.3 이하는 LXP 편집 화면 저장(초안) 실패, npm update @eliceio/cdk)"},{id:"sdk.lib-copy",level:"error",scope:"client",title:"SDK 복사본 lib/cdk.js (zip에 넣지 않음, 프로젝트 검사만. SDK는 package.json 의존성 @eliceio/cdk를 build가 번들로 묶음)"}];var rulesJson = {version:version,manifest:manifest,externalAllow:externalAllow,minVersions:minVersions,layouts:layouts,limits:limits,allowedExtensions:allowedExtensions,imageExtensions:imageExtensions,excluded:excluded,forbiddenApis:forbiddenApis,secretPatterns:secretPatterns,rules:rules};
|
|
2
2
|
|
|
3
|
-
export { allowedExtensions, rulesJson as default, excluded, externalAllow, forbiddenApis, imageExtensions, limits, manifest, minVersions, rules, secretPatterns, version };
|
|
3
|
+
export { allowedExtensions, rulesJson as default, excluded, externalAllow, forbiddenApis, imageExtensions, layouts, limits, manifest, minVersions, rules, secretPatterns, version };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eliceio/cdk-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-contenttypes.0",
|
|
4
4
|
"description": "교육자용 Custom HTML 콘텐츠 CLI",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"rollup": "^4.0.0",
|
|
47
47
|
"tslib": "^2.6.1",
|
|
48
48
|
"typescript": "~5.9.3",
|
|
49
|
-
"@eliceio/cdk": "^1.
|
|
49
|
+
"@eliceio/cdk": "^1.3.0-contenttypes.0"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"prebuild": "del-cli \"buildcache/*\" \"es/*\"",
|
package/rules.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.17.0",
|
|
3
3
|
"manifest": {
|
|
4
4
|
"file": "metadata.json",
|
|
5
5
|
"kinds": ["material", "description"],
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"material": ["learn", "instructor", "edit"],
|
|
11
11
|
"description": ["learn"]
|
|
12
12
|
},
|
|
13
|
-
"graderTypes": ["pattern", "rubric"],
|
|
13
|
+
"graderTypes": ["pattern", "partial_pattern", "rubric"],
|
|
14
14
|
"commentaryFile": "commentary.txt",
|
|
15
15
|
"defaultEntry": "index.html"
|
|
16
16
|
},
|
|
@@ -21,13 +21,18 @@
|
|
|
21
21
|
"minVersions": {
|
|
22
22
|
"sdk": "1.0.0-alpha.4"
|
|
23
23
|
},
|
|
24
|
+
"layouts": {
|
|
25
|
+
"content": ["single", "split", "stage", "media"],
|
|
26
|
+
"regions": ["main", "aside", "stage", "controls", "readout", "actions"]
|
|
27
|
+
},
|
|
24
28
|
"limits": {
|
|
25
29
|
"maxZipBytes": 20971520,
|
|
26
30
|
"maxUnpackedBytes": 209715200,
|
|
27
31
|
"maxFiles": 300,
|
|
28
32
|
"maxEntries": 3000,
|
|
29
33
|
"warnRatio": 0.8,
|
|
30
|
-
"maxImageBytes": 1048576
|
|
34
|
+
"maxImageBytes": 1048576,
|
|
35
|
+
"maxScreenBytes": 1572864
|
|
31
36
|
},
|
|
32
37
|
"allowedExtensions": [
|
|
33
38
|
"html",
|
|
@@ -419,6 +424,12 @@
|
|
|
419
424
|
"scope": "client",
|
|
420
425
|
"title": "한도에 가까움"
|
|
421
426
|
},
|
|
427
|
+
{
|
|
428
|
+
"id": "limit.screen-size",
|
|
429
|
+
"level": "warn",
|
|
430
|
+
"scope": "client",
|
|
431
|
+
"title": "화면 하나를 열 때 받는 JS · CSS가 큼 (기준 limits.maxScreenBytes, 큰 라이브러리는 import()로)"
|
|
432
|
+
},
|
|
422
433
|
{
|
|
423
434
|
"id": "path.unsafe",
|
|
424
435
|
"level": "error",
|
|
@@ -509,6 +520,18 @@
|
|
|
509
520
|
"scope": "client",
|
|
510
521
|
"title": "metadata.json build.template이 이 ecdk가 모르는 템플릿이거나 더 새 템플릿 버전"
|
|
511
522
|
},
|
|
523
|
+
{
|
|
524
|
+
"id": "layout.unknown",
|
|
525
|
+
"level": "warn",
|
|
526
|
+
"scope": "client",
|
|
527
|
+
"title": "data-ec-layout · data-ec-region에 키트가 모르는 값 (single · split · stage · media, main · aside · stage · controls · readout · actions)"
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
"id": "layout.own-step-nav",
|
|
531
|
+
"level": "warn",
|
|
532
|
+
"scope": "client",
|
|
533
|
+
"title": "화면 코드가 이전 · 다음 버튼을 직접 그림 (LXP 이전 · 다음 막대와 헷갈림, 키트 app.useStepper)"
|
|
534
|
+
},
|
|
512
535
|
{
|
|
513
536
|
"id": "ref.missing",
|
|
514
537
|
"level": "error",
|
|
@@ -641,6 +664,12 @@
|
|
|
641
664
|
"scope": "server",
|
|
642
665
|
"title": "비밀 값 (키 · 토큰 · 비밀번호)"
|
|
643
666
|
},
|
|
667
|
+
{
|
|
668
|
+
"id": "sec.answer-in-bundle",
|
|
669
|
+
"level": "warn",
|
|
670
|
+
"scope": "client",
|
|
671
|
+
"title": "편집 화면에 저장한 정답(.ecdk/settings.json 채점 설정)과 같은 글이 zip에 들어갈 파일에 있음 (프로젝트 검사만)"
|
|
672
|
+
},
|
|
644
673
|
{
|
|
645
674
|
"id": "sec.html-injection",
|
|
646
675
|
"level": "warn",
|
package/skills/_shared/always.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
## Always
|
|
2
2
|
|
|
3
|
-
- Answer the person in their language. The reference files are in English: `references/` next to this SKILL.md, read only the ones you need with the Read tool: 00 what the person decides · 01 environment · 02 design · 03 create the project · 04 sandbox rules · 05 screen code and kit API · 06 quiz template · 07 move existing HTML · 08 error ids · 09 check · 10 build and report · 11 more · 12 upload.
|
|
3
|
+
- Answer the person in their language. The reference files are in English: `references/` next to this SKILL.md, read only the ones you need with the Read tool: 00 what the person decides · 01 environment · 02 design · 03 create the project · 04 sandbox rules · 05 screen code and kit API · 06 quiz template · 07 move existing HTML · 08 error ids · 09 check · 10 build and report · 11 more · 12 upload · 13 edit screen design · 14 layouts and stepper.
|
|
4
4
|
- Never put correct answers in the content zip. The edit screen saves them to `settings.grading` (locally `.ecdk/settings.json` from `ecdk dev`, which stays local unless the person agrees to send it with the upload, `references/12-upload-with-the-material-mcp.md`).
|
|
5
5
|
- The completion policy is not in the project or the zip: it is a setting of the LXP page. Say which one fits (`references/02-design-the-material.md` ②); the elice-content-publish skill sets it with the upload after the person agrees (`on_graded` only with grading saved), otherwise the instructor picks it in the '설정' panel at the top of the LXP edit page. Only `on_graded` grades: `on_submit` completes on any submission without grading (`is_correct: null`, the kit shows "제출했어요."), `on_access` completes on open.
|
|
6
6
|
- The content runs in a sandboxed iframe on its own origin: use the SDK (`app.useSubmit`, `app.useSave`) for anything that must be kept (storage and cookies stay only in that browser), and in-page UI instead of `alert`/`confirm`, new windows, the parent window or external requests.
|
|
7
7
|
- The content CSP blocks external images, fonts, video, CSS, `<iframe>` and external APIs: put everything in the zip (fonts as files or data URIs). If a library calls outside hosts while running, that is blocked too → check the `ecdk dev` log for "막힌 외부 요청".
|
|
8
8
|
- Fix every `ecdk validate` / `ecdk build` error before you report. Do not edit `lib/` (the screen kit). The SDK comes from npm through `package.json` (`npm update @eliceio/cdk`); the kit imports it and `ecdk build` (Vite) bundles it into the screens. Never copy SDK code into the project.
|
|
9
9
|
- Ask the person before you settle correct answers (they confirm them before answers go with an upload), install anything globally, or upload or save to LXP (a saved version is visible to learners at once). Before uploading, confirm the exact target page (기관 · 과목 · 수업 · 페이지) with the person.
|
|
10
|
-
-
|
|
10
|
+
- Lay out screens with the kit, not your own frame: a content layout `data-ec-layout` (`single` · `split` · `stage` · `media`) with content in `data-ec-region` boxes, and for steps inside a material the kit stepper `app.useStepper()` with `<section data-ec-step>` (`references/14-layouts.md`). LXP draws its own 이전 · 다음 bar under the material, so never build your own Back/Next buttons, `n / N` or a bottom bar.
|
|
11
11
|
|
|
12
12
|
## Progress and live preview
|
|
13
13
|
|
|
14
14
|
- At the start, show a short numbered plan (for example `1 설계 → 2 프로젝트 → 3 학생 화면 → 4 편집 화면 → 5 확인 → 6 zip`). Before and after each step write one line: `[3/6] 학생 화면 만드는 중: …` and `[3/6] 끝: … · 다음: …`.
|
|
15
15
|
- Right after `ecdk create` (or when you start on an existing project), start `ecdk dev <folder>` in the background and give the person the URL it prints (`http://localhost:4170` unless that port is taken), so they watch the screens change while you write code. Claude Code: run it as a background command. Helpy Code: the tool's background option, or `zsh -ilc 'ecdk dev <folder> > /tmp/ecdk-dev.log 2>&1 &'` and read the URL from that log. Do not wait for the person.
|
|
16
|
-
- Check screens only with `ecdk dev [folder] --check [--screens learn,tutoring,instructor,edit] [--viewport desktop,mobile] [--json]`. Never write your own browser-automation script (Playwright, Puppeteer, …). After each screen, run it (`--screens <that screen>`), tell the person the result lines, the screenshots `.ecdk/screens/<screen>-<viewport>.png` (Claude Code: Read the PNG to see it; otherwise give the path) and what to try in the browser (it checks only the first state, no clicks or submits). First make sure `ecdk dev --help` lists `--check` (an older ecdk does not have it). To see the student screen with content, write sample content to `.ecdk/settings.json` first (`references/09-check.md`). Exit 1: fix and run again (at most twice). Exit 3 (no browser), an unknown option (an older ecdk) or a problem you cannot fix: stop checking and ask the person to look at the dev URL (`references/09-check.md`).
|
|
16
|
+
- Check screens only with `ecdk dev [folder] --check [--screens learn,tutoring,instructor,edit] [--viewport desktop,mobile] [--step all] [--theme all] [--json]`. Never write your own browser-automation script (Playwright, Puppeteer, …). After each screen, run it (`--screens <that screen>`), tell the person the result lines, the screenshots `.ecdk/screens/<screen>-<viewport>.png` (Claude Code: Read the PNG to see it; otherwise give the path) and what to try in the browser (it checks only the first state, no clicks or submits). First make sure `ecdk dev --help` lists `--check` (an older ecdk does not have it). To see the student screen with content, write sample content to `.ecdk/settings.json` first (`references/09-check.md`). Exit 1: fix and run again (at most twice). Exit 3 (no browser), an unknown option (an older ecdk) or a problem you cannot fix: stop checking and ask the person to look at the dev URL (`references/09-check.md`).
|
|
17
17
|
- While `ecdk dev` runs, do not run `ecdk validate` again and again: dev checks again on every change and `--check` prints the validation summary. Run `ecdk validate` once before building (or let `ecdk build` check).
|
|
18
18
|
- If `ecdk`, `node` or `npm` is "command not found", the app started without the person's shell PATH (macOS desktop apps such as Helpy Code Desktop). Find the paths once with `"$SHELL" -ilc 'command -v ecdk node npm'` (`zsh -ilc` when `$SHELL` is empty), then run commands with absolute paths and node's folder first on PATH: `PATH="/opt/homebrew/bin:$PATH" /opt/homebrew/bin/ecdk build --json`. If that fails, run the command through the login shell (`"$SHELL" -ilc 'ecdk build --json'`; with `--json` read only the last JSON block). If that also fails, ask the person how Node was installed.
|
|
@@ -4,7 +4,7 @@ The person (the instructor or author) is responsible for the content and its ans
|
|
|
4
4
|
|
|
5
5
|
1. **The learning goal, when it is unclear.** Decide the rest of the design to fit the goal and tell the person briefly what you decided.
|
|
6
6
|
2. **Correct answers.** You may draft answers and rubrics, but the person confirms that they are right, before they go with an upload.
|
|
7
|
-
3. **How it is graded**: whether the student submits, and the grader (`pattern` or `rubric`) set on the edit screen. Propose what fits the material and get a confirmation. **The completion policy**: propose the one that fits (the table in 2 ②) and get a yes before the upload sets it (2026-11-12: the publish skill can set it with the save; otherwise the instructor picks it in the '설정' panel at the top of the LXP edit page). Only `on_graded` grades: `on_submit` completes on any submission without grading (`is_correct: null`, the kit shows "제출했어요."), `on_access` completes on open.
|
|
7
|
+
3. **How it is graded**: whether the student submits, and the grader (`pattern`, `partial_pattern` for a score per question, or `rubric`) set on the edit screen. Propose what fits the material and get a confirmation. **The completion policy**: propose the one that fits (the table in 2 ②) and get a yes before the upload sets it (2026-11-12: the publish skill can set it with the save; otherwise the instructor picks it in the '설정' panel at the top of the LXP edit page). Only `on_graded` grades: `on_submit` completes on any submission without grading (`is_correct: null`, the kit shows "제출했어요."), `on_access` completes on open.
|
|
8
8
|
4. **What the learning notes say** (`commentary.txt`). A material needs them (LXP rejects the upload without them); once they are filled in, AI Helpy answers only questions about this material, so let the person check the wording.
|
|
9
9
|
5. **Checking the screens.** The person looks at the student, tutoring, instructor, edit and mobile views in the preview. When they cannot, tell them what to check and in which order.
|
|
10
10
|
6. **Uploading to LXP.** A saved version is **visible to learners at once** (when the page is open). Before uploading, show what changes and get approval. The same goes for changing a material that is already open, changing answers, and restoring an older version.
|