@eliceio/cdk-cli 0.0.0-stage → 0.1.0-alpha.1
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 +511 -2
- package/es/bin/index.d.ts +2 -0
- package/es/bin/index.js +10 -0
- package/es/cli.d.ts +5 -0
- package/es/cli.js +171 -0
- package/es/commands/build/index.d.ts +27 -0
- package/es/commands/build/index.js +154 -0
- package/es/commands/check/index.d.ts +9 -0
- package/es/commands/check/index.js +31 -0
- package/es/commands/create/index.d.ts +8 -0
- package/es/commands/create/index.js +22 -0
- package/es/commands/create/scaffold.d.ts +24 -0
- package/es/commands/create/scaffold.js +82 -0
- package/es/commands/dev/index.d.ts +6 -0
- package/es/commands/dev/index.js +40 -0
- package/es/commands/doctor/index.d.ts +33 -0
- package/es/commands/doctor/index.js +230 -0
- package/es/core/collect.d.ts +21 -0
- package/es/core/collect.js +89 -0
- package/es/core/config.d.ts +55 -0
- package/es/core/config.js +109 -0
- package/es/core/manifest.d.ts +15 -0
- package/es/core/manifest.js +43 -0
- package/es/core/minify.d.ts +18 -0
- package/es/core/minify.js +93 -0
- package/es/core/prepare.d.ts +12 -0
- package/es/core/prepare.js +86 -0
- package/es/core/protocol.d.ts +2 -0
- package/es/core/protocol.js +4 -0
- package/es/core/zip.d.ts +4 -0
- package/es/core/zip.js +17 -0
- package/es/dev/grading.d.ts +15 -0
- package/es/dev/grading.js +37 -0
- package/es/dev/host-page.d.ts +7 -0
- package/es/dev/host-page.js +240 -0
- package/es/dev/inject.d.ts +8 -0
- package/es/dev/inject.js +38 -0
- package/es/dev/mock-api.d.ts +65 -0
- package/es/dev/mock-api.js +269 -0
- package/es/dev/server.d.ts +24 -0
- package/es/dev/server.js +294 -0
- package/es/engines/static/index.d.ts +3 -0
- package/es/engines/static/index.js +11 -0
- package/es/engines/types.d.ts +12 -0
- package/es/engines/vite/index.d.ts +2 -0
- package/es/engines/vite/index.js +4 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +2 -0
- package/es/rules/check.d.ts +2 -0
- package/es/rules/check.js +209 -0
- package/es/rules/index.d.ts +8 -0
- package/es/rules/index.js +7 -0
- package/es/rules/manifest.d.ts +39 -0
- package/es/rules/manifest.js +168 -0
- package/es/rules/node.d.ts +11 -0
- package/es/rules/node.js +87 -0
- package/es/rules/path.d.ts +7 -0
- package/es/rules/path.js +35 -0
- package/es/rules/refs.d.ts +19 -0
- package/es/rules/refs.js +111 -0
- package/es/rules/skip.d.ts +12 -0
- package/es/rules/skip.js +55 -0
- package/es/rules/spec.d.ts +3 -0
- package/es/rules/spec.js +6 -0
- package/es/rules/types.d.ts +138 -0
- package/es/rules/unused.d.ts +7 -0
- package/es/rules/unused.js +21 -0
- package/es/rules/zip.d.ts +13 -0
- package/es/rules/zip.js +45 -0
- package/es/rules.json.js +3 -0
- package/es/types.d.ts +4 -0
- package/es/version.d.ts +1 -0
- package/es/version.js +3 -0
- package/package.json +48 -3
- package/rules.json +555 -0
- package/templates/_shared/lib/cdk-mock.d.ts +94 -0
- package/templates/_shared/lib/cdk-mock.js +429 -0
- package/templates/_shared/lib/cdk.js +3 -0
- package/templates/_shared/lib/elice-content.css +252 -0
- package/templates/_shared/lib/elice-content.d.ts +121 -0
- package/templates/_shared/lib/elice-content.js +541 -0
- package/templates/_shared/lib/elice-tokens.css +446 -0
- package/templates/blank/README.md +64 -0
- package/templates/blank/content.json +4 -0
- package/templates/blank/edit.html +15 -0
- package/templates/blank/elice.config.json +12 -0
- package/templates/blank/gitignore +3 -0
- package/templates/blank/index.html +15 -0
- package/templates/blank/instructor.html +15 -0
- package/templates/blank/screens/edit.js +21 -0
- package/templates/blank/screens/instructor.js +9 -0
- package/templates/blank/screens/learn.js +19 -0
- package/templates/blank/styles.css +1 -0
- package/templates/quiz/README.md +108 -0
- package/templates/quiz/content.json +81 -0
- package/templates/quiz/core/behaviors.d.ts +59 -0
- package/templates/quiz/core/behaviors.js +309 -0
- package/templates/quiz/core/dom.d.ts +13 -0
- package/templates/quiz/core/dom.js +83 -0
- package/templates/quiz/core/editor.d.ts +48 -0
- package/templates/quiz/core/editor.js +206 -0
- package/templates/quiz/core/markdown.d.ts +2 -0
- package/templates/quiz/core/markdown.js +84 -0
- package/templates/quiz/core/model.d.ts +20 -0
- package/templates/quiz/core/model.js +203 -0
- package/templates/quiz/edit.html +17 -0
- package/templates/quiz/elice.config.json +14 -0
- package/templates/quiz/gitignore +3 -0
- package/templates/quiz/grading.json +13 -0
- package/templates/quiz/index.html +17 -0
- package/templates/quiz/instructor.html +17 -0
- package/templates/quiz/screens/edit.js +139 -0
- package/templates/quiz/screens/instructor.js +27 -0
- package/templates/quiz/screens/learn.js +50 -0
- package/templates/quiz/styles.css +510 -0
- package/templates/quiz/ui/templates/choice.js +22 -0
- package/templates/quiz/ui/templates/edit.d.ts +14 -0
- package/templates/quiz/ui/templates/edit.js +187 -0
- package/templates/quiz/ui/templates/group.js +47 -0
- package/templates/quiz/ui/templates/index.d.ts +5 -0
- package/templates/quiz/ui/templates/index.js +17 -0
- package/templates/quiz/ui/templates/order.js +35 -0
- package/templates/quiz/ui/templates/page.js +29 -0
- package/templates/quiz/ui/templates/question.js +28 -0
- package/templates/quiz/ui/templates/text.js +16 -0
- package/templates/quiz/ui/texts.d.ts +3 -0
- package/templates/quiz/ui/texts.js +128 -0
- package/templates/quiz/ui/theme.css +50 -0
package/es/rules/refs.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
const TAG = /<([a-zA-Z][\w-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g;
|
|
2
|
+
const ATTR = /([^\s"'=<>/]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g;
|
|
3
|
+
const RAW_BLOCK = /<(script|style)\b[^>]*>([\s\S]*?)<\/\1\s*>/gi;
|
|
4
|
+
const CSS_URL = /url\(\s*(?:"([^"]*)"|'([^']*)'|([^)'"\s]+))\s*\)|@import\s+(?:"([^"]*)"|'([^']*)')/g;
|
|
5
|
+
const JS_IMPORT = /\b(?:import|export)\b[^'"`;]*?\bfrom\s*(?:"([^"]*)"|'([^']*)')|\bimport\s+(?:"([^"]*)"|'([^']*)')|\bimport\s*\(\s*(?:"([^"]*)"|'([^']*)')\s*\)/g;
|
|
6
|
+
function lineAt(text, index) {
|
|
7
|
+
let n = 1;
|
|
8
|
+
for (let i = 0; i < index; i++) if (text.charCodeAt(i) === 10) n++;
|
|
9
|
+
return n;
|
|
10
|
+
}
|
|
11
|
+
function collect(text, re, role, out, lineBase = 0) {
|
|
12
|
+
for (const m of text.matchAll(re)) {
|
|
13
|
+
const raw = m.slice(1).find(g => g !== undefined);
|
|
14
|
+
if (raw !== undefined) out.push({
|
|
15
|
+
value: raw.trim(),
|
|
16
|
+
line: lineAt(text, m.index) + lineBase,
|
|
17
|
+
role
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** <script>·<style> 본문을 같은 줄 수의 빈 칸으로 바꾼다. 스크립트 안의 `a<b` 같은 글자를 태그로 읽지 않도록. */
|
|
22
|
+
function blankRawBlocks(html) {
|
|
23
|
+
return html.replace(RAW_BLOCK, (all, _tag, body) => all.replace(body, body.replace(/[^\n]/g, ' ')));
|
|
24
|
+
}
|
|
25
|
+
function parseTags(html) {
|
|
26
|
+
const text = blankRawBlocks(html);
|
|
27
|
+
const tags = [];
|
|
28
|
+
for (const m of text.matchAll(TAG)) {
|
|
29
|
+
const attrs = new Map();
|
|
30
|
+
for (const a of (m[2] ?? '').matchAll(ATTR)) {
|
|
31
|
+
if (a[1]) attrs.set(a[1].toLowerCase(), a[2] ?? a[3] ?? a[4] ?? '');
|
|
32
|
+
}
|
|
33
|
+
tags.push({
|
|
34
|
+
name: (m[1] ?? '').toLowerCase(),
|
|
35
|
+
attrs,
|
|
36
|
+
line: lineAt(text, m.index)
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return tags;
|
|
40
|
+
}
|
|
41
|
+
const RESOURCE_ATTRS = ['src', 'poster', 'data'];
|
|
42
|
+
function tagRefs(tags, out) {
|
|
43
|
+
for (const t of tags) {
|
|
44
|
+
const push = (value, role) => out.push({
|
|
45
|
+
value: value.trim(),
|
|
46
|
+
line: t.line,
|
|
47
|
+
role
|
|
48
|
+
});
|
|
49
|
+
if (t.name === 'script') {
|
|
50
|
+
const src = t.attrs.get('src');
|
|
51
|
+
if (src !== undefined) push(src, 'script');
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const href = t.attrs.get('href');
|
|
55
|
+
if (href !== undefined) {
|
|
56
|
+
if (t.name === 'a' || t.name === 'area') push(href, 'link');else if (t.name === 'link') {
|
|
57
|
+
const rel = t.attrs.get('rel') ?? '';
|
|
58
|
+
push(href, /\bmodulepreload\b/i.test(rel) ? 'script' : 'resource');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
for (const a of RESOURCE_ATTRS) {
|
|
62
|
+
const v = t.attrs.get(a);
|
|
63
|
+
if (v !== undefined) push(v, 'resource');
|
|
64
|
+
}
|
|
65
|
+
const srcset = t.attrs.get('srcset');
|
|
66
|
+
if (srcset !== undefined) {
|
|
67
|
+
for (const part of srcset.split(',')) push(part.trim().split(/\s+/)[0] ?? '', 'resource');
|
|
68
|
+
}
|
|
69
|
+
const style = t.attrs.get('style');
|
|
70
|
+
if (style !== undefined) {
|
|
71
|
+
const inner = [];
|
|
72
|
+
collect(style, CSS_URL, 'resource', inner);
|
|
73
|
+
out.push(...inner.map(r => ({
|
|
74
|
+
...r,
|
|
75
|
+
line: t.line
|
|
76
|
+
})));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** HTML 태그 속성, CSS url()·@import, JS 정적·동적 import의 문자열 리터럴 참조. 스크립트가 만든 경로(fetch 등)는 못 잡는다. */
|
|
81
|
+
function extractRefs(kind, text, tags) {
|
|
82
|
+
const out = [];
|
|
83
|
+
if (kind === 'css') {
|
|
84
|
+
collect(text, CSS_URL, 'resource', out);
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
if (kind === 'js') return jsRefs(text, 0);
|
|
88
|
+
tagRefs(tags ?? parseTags(text), out);
|
|
89
|
+
for (const m of text.matchAll(RAW_BLOCK)) {
|
|
90
|
+
const [all, tag, body] = m;
|
|
91
|
+
if (body === undefined) continue;
|
|
92
|
+
const base = lineAt(text, m.index + all.indexOf(body)) - 1;
|
|
93
|
+
if (tag?.toLowerCase() === 'style') collect(body, CSS_URL, 'resource', out, base);else out.push(...jsRefs(body, base));
|
|
94
|
+
}
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
/** 상대경로와 외부 주소 import만. bare specifier('lodash')는 import map이 있을 수 있어 건너뜀 */
|
|
98
|
+
function jsRefs(text, lineBase) {
|
|
99
|
+
const out = [];
|
|
100
|
+
collect(text, JS_IMPORT, 'script', out, lineBase);
|
|
101
|
+
return out.filter(r => /^(?:\.{0,2}\/|https?:)/i.test(r.value));
|
|
102
|
+
}
|
|
103
|
+
function classifyRef(value) {
|
|
104
|
+
if (value === '' || value.startsWith('#') || value.includes('{{') || value.includes('${')) return 'skip';
|
|
105
|
+
if (/^(?:https?:)?\/\//i.test(value)) return 'external';
|
|
106
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(value)) return 'skip';
|
|
107
|
+
if (value.startsWith('/')) return 'root';
|
|
108
|
+
return 'local';
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export { classifyRef, extractRefs, lineAt, parseTags };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** 줄마다 "주석뿐인 줄인가" (빈 줄 포함) */
|
|
2
|
+
export declare function commentOnlyLines(lines: string[]): boolean[];
|
|
3
|
+
/**
|
|
4
|
+
* 텍스트의 줄 건너뛰기 판정. `line`은 1부터.
|
|
5
|
+
* skipComments: false면 주석 줄도 본다 (비밀 값처럼 주석 안에 있어도 문제인 규칙).
|
|
6
|
+
*/
|
|
7
|
+
export declare function lineSkipper(text: string, { skipComments }?: {
|
|
8
|
+
skipComments?: boolean | undefined;
|
|
9
|
+
}): {
|
|
10
|
+
lines: string[];
|
|
11
|
+
isSkipped(line: number, id: string): boolean;
|
|
12
|
+
};
|
package/es/rules/skip.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 검사에서 뺄 줄. 금지 API 검사(check) · 정답 파일 참조 검사(ecdk doctor)가 같이 쓴다.
|
|
3
|
+
*
|
|
4
|
+
* - 줄 **전체**가 주석인 줄: `//` 줄, `/* … *\/`·`<!-- … -->` 블록 안의 줄(JSDoc 가운데 줄 포함).
|
|
5
|
+
* `/* x *\/ localStorage.x`처럼 주석 뒤에 코드가 있으면 건너뛰지 않는다 (주석으로 규칙을 피하지 못하게).
|
|
6
|
+
* - eslint-disable처럼 끈 줄. 정규식이 구분하지 못하는 경우(try/catch로 감싼 코드 등)에 쓴다.
|
|
7
|
+
* // ecdk-ignore-next-line api.storage (다음 줄)
|
|
8
|
+
* localStorage.getItem('k'); // ecdk-ignore api.storage (같은 줄)
|
|
9
|
+
*
|
|
10
|
+
* 줄 중간에서 열린 블록 주석은 따라가지 않는다: 문자열 속 `/*`를 주석으로 잘못 보면 코드를 놓치므로,
|
|
11
|
+
* 모르면 코드로 보고 검사하는 쪽을 택한다.
|
|
12
|
+
*/
|
|
13
|
+
const BLOCKS = [['/*', '*/'], ['<!--', '-->']];
|
|
14
|
+
/** 줄마다 "주석뿐인 줄인가" (빈 줄 포함) */
|
|
15
|
+
function commentOnlyLines(lines) {
|
|
16
|
+
let close = null;
|
|
17
|
+
return lines.map(raw => {
|
|
18
|
+
let rest = raw.trim();
|
|
19
|
+
while (rest) {
|
|
20
|
+
if (close) {
|
|
21
|
+
const end = rest.indexOf(close);
|
|
22
|
+
if (end < 0) return true;
|
|
23
|
+
rest = rest.slice(end + close.length).trim();
|
|
24
|
+
close = null;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (rest.startsWith('//')) return true;
|
|
28
|
+
const block = BLOCKS.find(([open]) => rest.startsWith(open));
|
|
29
|
+
if (!block) return false;
|
|
30
|
+
close = block[1];
|
|
31
|
+
rest = rest.slice(block[0].length);
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 텍스트의 줄 건너뛰기 판정. `line`은 1부터.
|
|
38
|
+
* skipComments: false면 주석 줄도 본다 (비밀 값처럼 주석 안에 있어도 문제인 규칙).
|
|
39
|
+
*/
|
|
40
|
+
function lineSkipper(text, {
|
|
41
|
+
skipComments = true
|
|
42
|
+
} = {}) {
|
|
43
|
+
const lines = text.split('\n');
|
|
44
|
+
const comment = skipComments ? commentOnlyLines(lines) : [];
|
|
45
|
+
const directive = (line, kind, id) => new RegExp(`${kind}(?:\\s+[\\w.,-]+)*?\\s+(?:${id.replaceAll('.', '\\.')}|all)\\b`).test(line);
|
|
46
|
+
return {
|
|
47
|
+
lines,
|
|
48
|
+
isSkipped(line, id) {
|
|
49
|
+
if (comment[line - 1]) return true;
|
|
50
|
+
return directive(lines[line - 1] ?? '', 'ecdk-ignore', id) || directive(lines[line - 2] ?? '', 'ecdk-ignore-next-line', id);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { commentOnlyLines, lineSkipper };
|
package/es/rules/spec.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
export type Level = 'error' | 'warn';
|
|
2
|
+
/** server: 서버 업로드 검사도 rules.json만으로 같은 판정을 낼 수 있는 규칙. client: CLI·웹 편집기에서만 검사. */
|
|
3
|
+
export type Scope = 'server' | 'client';
|
|
4
|
+
export interface RuleDef {
|
|
5
|
+
id: string;
|
|
6
|
+
level: Level;
|
|
7
|
+
scope: Scope;
|
|
8
|
+
title: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ExcludeGroup {
|
|
11
|
+
level: Level;
|
|
12
|
+
/** 파일 이름(basename) glob. `*`만 지원 */
|
|
13
|
+
files: string[];
|
|
14
|
+
/** 경로 어디에 있든 이 이름의 폴더 */
|
|
15
|
+
dirs: string[];
|
|
16
|
+
}
|
|
17
|
+
export interface RulesSpec {
|
|
18
|
+
version: string;
|
|
19
|
+
manifest: {
|
|
20
|
+
file: string;
|
|
21
|
+
/** 콘텐츠 용도. material: 자료 본문, description: 다른 자료(실습 등)의 문제 설명 */
|
|
22
|
+
kinds: string[];
|
|
23
|
+
/** kind가 없을 때 */
|
|
24
|
+
defaultKind: string;
|
|
25
|
+
modes: string[];
|
|
26
|
+
required: string[];
|
|
27
|
+
/** 용도별로 지원할 수 있는 화면. 문제 설명은 학생 화면만 */
|
|
28
|
+
kindModes: Record<string, string[]>;
|
|
29
|
+
/** metadata.json `gradingTypes`에 쓸 수 있는 채점 유형. 수동 채점(manual) · 채점 없음(none)은 없음 */
|
|
30
|
+
gradingTypes: string[];
|
|
31
|
+
/** 학습 참고 내용(commentary) 파일의 기본 이름 (zip 최상위, 일반 텍스트). metadata.json `commentary`가 가리킨다 */
|
|
32
|
+
commentaryFile: string;
|
|
33
|
+
defaultEntry: string;
|
|
34
|
+
};
|
|
35
|
+
limits: {
|
|
36
|
+
maxZipBytes: number;
|
|
37
|
+
/** zip을 풀었을 때 합계. 넘으면 다 풀기 전에 멈춘다 (압축 폭탄) */
|
|
38
|
+
maxUnpackedBytes: number;
|
|
39
|
+
maxFiles: number;
|
|
40
|
+
/** zip 항목 수. 넘으면 풀기 전에 멈춘다 (maxFiles 검사는 그 아래에서) */
|
|
41
|
+
maxEntries: number;
|
|
42
|
+
warnRatio: number;
|
|
43
|
+
maxImageBytes: number;
|
|
44
|
+
};
|
|
45
|
+
allowedExtensions: string[];
|
|
46
|
+
imageExtensions: string[];
|
|
47
|
+
excluded: {
|
|
48
|
+
secret: ExcludeGroup;
|
|
49
|
+
dev: ExcludeGroup;
|
|
50
|
+
junk: ExcludeGroup;
|
|
51
|
+
};
|
|
52
|
+
forbiddenApis: {
|
|
53
|
+
id: string;
|
|
54
|
+
pattern: string;
|
|
55
|
+
title: string;
|
|
56
|
+
}[];
|
|
57
|
+
secretPatterns: SecretPattern[];
|
|
58
|
+
rules: RuleDef[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 비밀 값 탐지 (`sec.secret`). 사내 SAST(semgrep p/secrets + security/semgrep custom)를 옮긴 것.
|
|
62
|
+
* 텍스트 파일 전체를 주석 포함으로 본다. Python `re`에서도 같은 뜻으로 동작하는 문법만 쓴다.
|
|
63
|
+
*/
|
|
64
|
+
export interface SecretPattern {
|
|
65
|
+
/** 원래 semgrep 규칙 이름 */
|
|
66
|
+
source: string;
|
|
67
|
+
title: string;
|
|
68
|
+
pattern: string;
|
|
69
|
+
/** `i` · `m` */
|
|
70
|
+
flags?: string | undefined;
|
|
71
|
+
/** 걸린 부분이 이것과 맞으면 제외 (대소문자 무시). 예시 · 자리표시 값 */
|
|
72
|
+
not?: string | undefined;
|
|
73
|
+
}
|
|
74
|
+
export interface ContentFile {
|
|
75
|
+
/** zip 안 이름 그대로 (폴더 기준 상대경로, `/` 구분) */
|
|
76
|
+
path: string;
|
|
77
|
+
/** zip의 폴더 항목 */
|
|
78
|
+
dir?: boolean | undefined;
|
|
79
|
+
data: Uint8Array;
|
|
80
|
+
}
|
|
81
|
+
export interface CheckIssue {
|
|
82
|
+
id: string;
|
|
83
|
+
level: Level;
|
|
84
|
+
message: string;
|
|
85
|
+
path?: string | undefined;
|
|
86
|
+
line?: number | undefined;
|
|
87
|
+
}
|
|
88
|
+
/** 서버 판정과 맞추려면 입력 종류가 필요하다: 단일 HTML은 metadata.json이 없어도 되고, zip은 실제 zip 크기로 한도를 본다. */
|
|
89
|
+
export type InputKind = 'zip' | 'dir' | 'html';
|
|
90
|
+
export interface CheckOptions {
|
|
91
|
+
input?: InputKind | undefined;
|
|
92
|
+
/** 이미 만든 zip의 크기. 없으면 검사기가 압축해 본 크기 */
|
|
93
|
+
zipBytes?: number | undefined;
|
|
94
|
+
spec?: RulesSpec | undefined;
|
|
95
|
+
}
|
|
96
|
+
/** metadata.json의 build: 어떤 도구·규칙으로 만들었는지. 서버가 "오래된 규칙" 같은 안내에 쓴다 */
|
|
97
|
+
export interface BuildInfo {
|
|
98
|
+
cli: string;
|
|
99
|
+
rules: string;
|
|
100
|
+
protocol: number;
|
|
101
|
+
engine: string;
|
|
102
|
+
/** 만든 템플릿과 버전 (예: "quiz@0.1.0"). ecdk create가 elice.config.json에 적어 둔 값 */
|
|
103
|
+
template?: string | undefined;
|
|
104
|
+
/** 묶어 넣은 @eliceio/cdk 버전 (lib/cdk.js 머리말) */
|
|
105
|
+
sdk?: string | undefined;
|
|
106
|
+
/** minify로 줄였는지 */
|
|
107
|
+
minify?: boolean | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* zip 내용의 지문: metadata.json을 뺀 파일을 이름순으로 경로 · 내용을 이어 SHA-256 (base64).
|
|
110
|
+
* 빌드 뒤 파일이 바뀌었는지 확인하는 용도. 누구나 계산할 수 있어 "ecdk로 만들었다"는 증명은 아니다
|
|
111
|
+
*/
|
|
112
|
+
digest?: string | undefined;
|
|
113
|
+
}
|
|
114
|
+
export interface Manifest {
|
|
115
|
+
/** 용도 (자료 본문 · 문제 설명). 없으면 spec.manifest.defaultKind */
|
|
116
|
+
kind?: string | undefined;
|
|
117
|
+
/** 켠 화면 → 진입 파일 (metadata.json `screens`에서 enabled: true인 것만) */
|
|
118
|
+
entries: Record<string, string>;
|
|
119
|
+
/** 채점 유형만 (정답은 LXP 채점 설정). 문제 설명에는 없음 */
|
|
120
|
+
/** 이 자료가 지원하는 채점 유형 (자료 본문은 필수). 교육자가 LXP 채점 설정에서 하나를 고른다 */
|
|
121
|
+
gradingTypes?: string[] | undefined;
|
|
122
|
+
/** 학습 참고 내용 파일 (zip 최상위 .txt). LXP "AI헬피 설정 → 학습 참고 내용"(lecture page `commentary`)으로 들어간다 */
|
|
123
|
+
commentary?: string | undefined;
|
|
124
|
+
/** ecdk build가 채움. 직접 만든 zip에는 없어도 됨 */
|
|
125
|
+
build?: BuildInfo | undefined;
|
|
126
|
+
}
|
|
127
|
+
export interface CheckResult {
|
|
128
|
+
ok: boolean;
|
|
129
|
+
rulesVersion: string;
|
|
130
|
+
/** 서버가 최상위 폴더를 벗겨 낸 뒤의 경로 기준 */
|
|
131
|
+
stats: {
|
|
132
|
+
files: number;
|
|
133
|
+
totalBytes: number;
|
|
134
|
+
zipBytes: number;
|
|
135
|
+
};
|
|
136
|
+
manifest: Manifest | null;
|
|
137
|
+
issues: CheckIssue[];
|
|
138
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ContentFile, Manifest } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* 어디서도 이름이 나오지 않는 파일 (용량을 줄일 후보). 다른 텍스트 파일에 경로나 파일 이름이 한 번이라도
|
|
4
|
+
* 나오면 쓰는 것으로 본다: JS에서 `img/${n}.png`처럼 이름을 조합하면 못 찾으므로 일부러 넓게 본다.
|
|
5
|
+
* metadata.json과 화면 진입 파일은 늘 쓰는 것으로 친다.
|
|
6
|
+
*/
|
|
7
|
+
export declare function findUnreferenced(files: ContentFile[], manifest: Manifest | null): string[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const TEXT = /\.(?:html?|css|m?js|json|svg)$/i;
|
|
2
|
+
/**
|
|
3
|
+
* 어디서도 이름이 나오지 않는 파일 (용량을 줄일 후보). 다른 텍스트 파일에 경로나 파일 이름이 한 번이라도
|
|
4
|
+
* 나오면 쓰는 것으로 본다: JS에서 `img/${n}.png`처럼 이름을 조합하면 못 찾으므로 일부러 넓게 본다.
|
|
5
|
+
* metadata.json과 화면 진입 파일은 늘 쓰는 것으로 친다.
|
|
6
|
+
*/
|
|
7
|
+
function findUnreferenced(files, manifest) {
|
|
8
|
+
const real = files.filter(f => !f.dir);
|
|
9
|
+
const entries = new Set(Object.values(manifest?.entries ?? {}));
|
|
10
|
+
const decoder = new TextDecoder();
|
|
11
|
+
const texts = real.filter(f => TEXT.test(f.path)).map(f => ({
|
|
12
|
+
path: f.path,
|
|
13
|
+
text: decoder.decode(f.data)
|
|
14
|
+
}));
|
|
15
|
+
return real.filter(f => f.path !== 'metadata.json' && !entries.has(f.path)).filter(f => {
|
|
16
|
+
const name = f.path.split('/').pop() ?? f.path;
|
|
17
|
+
return !texts.some(t => t.path !== f.path && (t.text.includes(f.path) || t.text.includes(name)));
|
|
18
|
+
}).map(f => f.path).sort();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { findUnreferenced };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ContentFile, RulesSpec } from './types.js';
|
|
2
|
+
/** 풀기 전에 멈춘 zip (압축 폭탄 의심). checkPath · 웹 편집기는 이걸 `limit.unpacked-size` 오류로 보여 준다 */
|
|
3
|
+
export declare class ZipLimitError extends Error {
|
|
4
|
+
readonly id = "limit.unpacked-size";
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* zip 안 항목을 이름 그대로 읽는다. 경로 검사는 checkFiles가 한다.
|
|
8
|
+
* 항목마다 풀기 **전에** 적힌 원래 크기 · 개수를 더해 보고, 한도를 넘으면 그 자리에서 멈춘다
|
|
9
|
+
* (다 푼 뒤 검사하면 CLI는 메모리를 다 쓰고 브라우저 탭은 멈춘다).
|
|
10
|
+
*/
|
|
11
|
+
export declare function filesFromZip(data: Uint8Array, spec?: RulesSpec): ContentFile[];
|
|
12
|
+
/** 단일 HTML 입력은 index.html 하나짜리 콘텐츠로 본다. */
|
|
13
|
+
export declare function filesFromHtml(html: string | Uint8Array): ContentFile[];
|
package/es/rules/zip.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { unzipSync } from 'fflate';
|
|
2
|
+
import { rules } from './spec.js';
|
|
3
|
+
|
|
4
|
+
/** 풀기 전에 멈춘 zip (압축 폭탄 의심). checkPath · 웹 편집기는 이걸 `limit.unpacked-size` 오류로 보여 준다 */
|
|
5
|
+
class ZipLimitError extends Error {
|
|
6
|
+
id = 'limit.unpacked-size';
|
|
7
|
+
}
|
|
8
|
+
const MB = 1024 * 1024;
|
|
9
|
+
/**
|
|
10
|
+
* zip 안 항목을 이름 그대로 읽는다. 경로 검사는 checkFiles가 한다.
|
|
11
|
+
* 항목마다 풀기 **전에** 적힌 원래 크기 · 개수를 더해 보고, 한도를 넘으면 그 자리에서 멈춘다
|
|
12
|
+
* (다 푼 뒤 검사하면 CLI는 메모리를 다 쓰고 브라우저 탭은 멈춘다).
|
|
13
|
+
*/
|
|
14
|
+
function filesFromZip(data, spec = rules) {
|
|
15
|
+
const {
|
|
16
|
+
maxUnpackedBytes,
|
|
17
|
+
maxEntries
|
|
18
|
+
} = spec.limits;
|
|
19
|
+
let total = 0;
|
|
20
|
+
let count = 0;
|
|
21
|
+
const entries = unzipSync(data, {
|
|
22
|
+
filter: f => {
|
|
23
|
+
total += f.originalSize;
|
|
24
|
+
count += 1;
|
|
25
|
+
if (count > maxEntries) throw new ZipLimitError(`zip 항목이 너무 많습니다 (${maxEntries}개 초과). 풀지 않고 멈췄습니다.`);
|
|
26
|
+
if (total > maxUnpackedBytes) throw new ZipLimitError(`풀면 ${Math.round(maxUnpackedBytes / MB)}MB를 넘는 zip입니다 (압축 폭탄 의심). 풀지 않고 멈췄습니다.`);
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return Object.entries(entries).map(([path, bytes]) => ({
|
|
31
|
+
path,
|
|
32
|
+
dir: path.endsWith('/'),
|
|
33
|
+
data: bytes
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
/** 단일 HTML 입력은 index.html 하나짜리 콘텐츠로 본다. */
|
|
37
|
+
function filesFromHtml(html) {
|
|
38
|
+
const data = typeof html === 'string' ? new TextEncoder().encode(html) : html;
|
|
39
|
+
return [{
|
|
40
|
+
path: 'index.html',
|
|
41
|
+
data
|
|
42
|
+
}];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { ZipLimitError, filesFromHtml, filesFromZip };
|
package/es/rules.json.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const version="0.2.0";const manifest={file:"metadata.json",kinds:["material","description"],defaultKind:"material",modes:["learn","instructor","edit"],required:["learn"],kindModes:{material:["learn","instructor","edit"],description:["learn"]},gradingTypes:["on_access","on_submit","pattern","rubric"],commentaryFile:"commentary.txt",defaultEntry:"index.html"};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"]},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:"쿠키 사용 (sandbox에서 예외가 남)"},{id:"api.storage",pattern:"\\b(?:localStorage|sessionStorage|indexedDB)\\b",title:"브라우저 저장소 사용 (sandbox에서 예외가 남, 입력값 저장은 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 대상이 * (아무 창이나 받을 수 있음)"}];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:"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:"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:"warn",scope:"client",title:"외부 리소스 요청 (글꼴·이미지 등이 막힐 수 있음)"},{id:"ref.insecure",level:"warn",scope:"client",title:"http:// 외부 리소스 (https 페이지에서 막힘)"},{id:"html.img-alt",level:"warn",scope:"client",title:"대체 텍스트 없는 이미지"},{id:"html.form",level:"warn",scope:"client",title:"form 제출 (sandbox에서 막힘, 버튼 click으로 처리)"},{id:"api.external-send",level:"error",scope:"client",title:"외부 주소로 요청 보냄"},{id:"api.parent-access",level:"warn",scope:"client",title:"부모 창 직접 접근"},{id:"api.cookie",level:"error",scope:"client",title:"쿠키 사용"},{id:"api.storage",level:"error",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 대상 *"}];var rulesJson = {version:version,manifest:manifest,limits:limits,allowedExtensions:allowedExtensions,imageExtensions:imageExtensions,excluded:excluded,forbiddenApis:forbiddenApis,secretPatterns:secretPatterns,rules:rules};
|
|
2
|
+
|
|
3
|
+
export { allowedExtensions, rulesJson as default, excluded, forbiddenApis, imageExtensions, limits, manifest, rules, secretPatterns, version };
|
package/es/types.d.ts
ADDED
package/es/version.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const VERSION = "0.0.0";
|
package/es/version.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eliceio/cdk-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"description": "교육자용 Custom HTML 콘텐츠 CLI",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./es/index.d.ts",
|
|
10
|
+
"import": "./es/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"es",
|
|
18
|
+
"rules.json",
|
|
19
|
+
"templates"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=20.19"
|
|
23
|
+
},
|
|
24
|
+
"bin": {
|
|
25
|
+
"ecdk": "./es/bin/index.js"
|
|
26
|
+
},
|
|
27
|
+
"browserslist": [
|
|
28
|
+
"node 20"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"esbuild": "~0.28.2",
|
|
32
|
+
"fflate": "^0.8.3"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@elice/rollup-config": "^1.260406.0",
|
|
36
|
+
"@types/node": "^24.12.4",
|
|
37
|
+
"cross-env": "^7.0.2",
|
|
38
|
+
"del-cli": "^3.0.1",
|
|
39
|
+
"rollup": "^4.0.0",
|
|
40
|
+
"tslib": "^2.6.1",
|
|
41
|
+
"typescript": "~5.9.3",
|
|
42
|
+
"@eliceio/cdk": "^1.0.0-alpha.1"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"prebuild": "del-cli \"buildcache/*\" \"es/*\" && node ../../scripts/copy-cdk.mjs",
|
|
46
|
+
"build": "cross-env NODE_ENV=production rollup -c ./rollup.config.ts --configPlugin typescript -f es",
|
|
47
|
+
"lint": "eslint src --max-warnings=0",
|
|
48
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
49
|
+
"test": "vitest run --root ../.. packages/eliceio-cdk-cli"
|
|
50
|
+
}
|
|
6
51
|
}
|