@eliceio/cdk-cli 0.1.0-alpha.5 → 0.1.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +45 -18
  2. package/es/commands/build/index.d.ts +1 -1
  3. package/es/commands/build/index.js +4 -4
  4. package/es/commands/dev/index.d.ts +1 -1
  5. package/es/commands/dev/index.js +1 -1
  6. package/es/commands/doctor/index.js +1 -1
  7. package/es/core/collect.js +1 -1
  8. package/es/core/config.js +1 -1
  9. package/es/core/prepare.js +1 -1
  10. package/es/core/sandbox.js +6 -3
  11. package/es/dev/host-page.js +18 -3
  12. package/es/dev/inject.d.ts +6 -0
  13. package/es/dev/inject.js +16 -1
  14. package/es/dev/mock-api.js +0 -16
  15. package/es/dev/server.d.ts +4 -2
  16. package/es/dev/server.js +11 -3
  17. package/es/rules/check.js +69 -6
  18. package/es/rules/csp.d.ts +26 -0
  19. package/es/rules/csp.js +42 -0
  20. package/es/rules/index.d.ts +1 -0
  21. package/es/rules/index.js +1 -0
  22. package/es/rules/refs.d.ts +12 -2
  23. package/es/rules/refs.js +50 -18
  24. package/es/rules/types.d.ts +5 -0
  25. package/es/rules.json.js +2 -2
  26. package/package.json +2 -2
  27. package/rules.json +37 -15
  28. package/skills/_shared/always.md +2 -1
  29. package/skills/elice-content-guide/SKILL.md +1 -1
  30. package/skills/elice-content-guide/topics/03-create-the-project.md +1 -1
  31. package/skills/elice-content-guide/topics/04-rules.md +3 -1
  32. package/skills/elice-content-guide/topics/07-move-existing-html.md +1 -1
  33. package/skills/elice-content-guide/topics/08-fix-check-errors.md +21 -18
  34. package/skills/elice-content-guide/topics/09-check.md +1 -0
  35. package/skills/elice-content-migrate/SKILL.md +4 -3
  36. package/templates/_shared/lib/cdk-mock.js +1 -1
  37. package/templates/_shared/lib/elice-content.css +22 -1
  38. package/templates/quiz/README.md +2 -2
  39. package/templates/quiz/core/editor.d.ts +2 -0
  40. package/templates/quiz/core/editor.js +16 -6
  41. package/templates/quiz/screens/edit.js +105 -24
  42. package/templates/quiz/styles.css +75 -12
  43. package/templates/quiz/template.json +1 -1
  44. package/templates/quiz/ui/templates/edit.d.ts +4 -0
  45. package/templates/quiz/ui/templates/edit.js +46 -10
  46. package/templates/quiz/ui/templates/page.js +1 -2
  47. package/templates/quiz/ui/templates/text.js +10 -7
  48. package/templates/quiz/ui/texts.js +12 -8
package/es/rules/check.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { zipSync } from 'fflate';
2
+ import { isAllowedExternal, allowedOrigins } from './csp.js';
2
3
  import { parseManifest } from './manifest.js';
3
4
  import { isUnsafePath, extname, globToRegExp, resolveRef } from './path.js';
4
- import { lineAt, parseTags, extractRefs, classifyRef } from './refs.js';
5
+ import { lineAt, parseTags, extractRefs, classifyRef, FRAME_TAGS } from './refs.js';
5
6
  import { compareVersions } from './semver.js';
6
7
  import { lineSkipper } from './skip.js';
7
8
  import { rules } from './spec.js';
@@ -125,6 +126,54 @@ function checkSdk(manifest, spec, opts, add) {
125
126
  function blankBundles(html) {
126
127
  return html.replace(/(<script\b[^>]*\sdata-ecdk-bundle\b[^>]*>)([\s\S]*?)(<\/script\s*>)/gi, (_, open, body, close) => open + body.replace(/[^\n]/g, '') + close);
127
128
  }
129
+ /** ecdk가 넣는 lib/ 파일 (SDK · 키트). 작성자가 넣은 라이브러리가 아니라 ref.vendor-external-url에서 뺀다 */
130
+ const ECDK_LIB_FILES = new Set(['lib/cdk.js', 'lib/elice-content.js', 'lib/cdk-mock.js']);
131
+ /** 작성자가 내려받아 넣은 라이브러리로 보는 폴더 · 파일 이름 */
132
+ const VENDOR_DIR = /^(?:vendors?|libs?|third[-_]?party|external|plugins?)$/i;
133
+ const VENDOR_FILE = /[.-]min\.m?js$/i;
134
+ function isVendorFile(path) {
135
+ if (ECDK_LIB_FILES.has(path) || !/\.m?js$/i.test(path)) return false;
136
+ return VENDOR_FILE.test(path) || path.split('/').slice(0, -1).some(seg => VENDOR_DIR.test(seg));
137
+ }
138
+ const ABSOLUTE_URL = /\bhttps?:\/\/[A-Za-z0-9][^\s'"`<>()\\]*/g;
139
+ /**
140
+ * 라이브러리가 실행 중 부르지 않는 주소: 라이선스 · 문서 · 오류 안내 링크, XML 이름공간, 로컬 주소.
141
+ * 너무 넓히면 실제 호출을 놓치므로 흔한 것만 (example.com 등은 남김)
142
+ */
143
+ const IGNORED_URL_HOST = /^(?:(?:[\w-]+\.)*(?:github\.com|github\.io|gitlab\.com|githubusercontent\.com|opensource\.org|mit-license\.org|apache\.org|gnu\.org|creativecommons\.org|spdx\.org|w3\.org|whatwg\.org|ietf\.org|ecma-international\.org|mozilla\.org|npmjs\.(?:com|org)|stackoverflow\.com|wikipedia\.org|jquery\.(?:com|org)|reactjs\.org|react\.dev|fb\.me|vuejs\.org|angular\.io|svelte\.dev|lodash\.com|underscorejs\.org|momentjs\.com|feross\.org|purl\.org|schema\.org|xmlsoap\.org|adobe\.com|microsoft\.com|openxmlformats\.org|goo\.gl|bit\.ly)|localhost|127\.0\.0\.1)$/i;
144
+ /** 라이브러리 파일 안의 실행 중 부를 수 있는 외부 주소 (호스트별 처음 하나) */
145
+ function vendorExternalUrls(text, spec) {
146
+ const allowed = new Set(allowedOrigins(spec));
147
+ const seen = new Set();
148
+ const out = [];
149
+ for (const m of text.matchAll(ABSOLUTE_URL)) {
150
+ const before = text.slice(Math.max(0, m.index - 40), m.index);
151
+ // sourceMappingURL · xmlns="…" · 주석 안 라이선스 줄(@license · @see · @link)
152
+ if (/(?:sourceMappingURL=|xmlns(?::\w+)?\s*[=:,]\s*['"]?|@(?:license|see|link|author|homepage)\b[^\n*]*)$/i.test(before)) continue;
153
+ let url;
154
+ try {
155
+ url = new URL(m[0]);
156
+ } catch {
157
+ continue;
158
+ }
159
+ if (IGNORED_URL_HOST.test(url.hostname) || allowed.has(url.origin) || seen.has(url.hostname)) continue;
160
+ seen.add(url.hostname);
161
+ out.push({
162
+ url: m[0],
163
+ line: lineAt(text, m.index)
164
+ });
165
+ }
166
+ return out;
167
+ }
168
+ /**
169
+ * html.iframe 대상인지. object · embed는 늘. iframe · frame은 src로 무엇을 띄울 때만: src가 없거나 빈 값 ·
170
+ * about:blank · about:srcdoc이면 통과 (srcdoc · JS로 채우는 미리보기는 frame-src 'none'에 걸리지 않음, Chromium 확인)
171
+ */
172
+ function framesSomething(t) {
173
+ if (t.name === 'object' || t.name === 'embed') return true;
174
+ const src = t.attrs.get('src')?.trim().toLowerCase();
175
+ return src !== undefined && src !== '' && src !== 'about:blank' && src !== 'about:srcdoc';
176
+ }
128
177
  function textKind(path) {
129
178
  const ext = extname(path);
130
179
  if (ext === 'html' || ext === 'htm') return 'html';
@@ -257,7 +306,8 @@ function checkFiles(input, opts = {}) {
257
306
  const type = classifyRef(ref.value);
258
307
  if (type === 'skip') return;
259
308
  if (type === 'external') {
260
- if (ref.role === 'script') add('ref.external-script', `외부 스크립트를 불러옵니다: ${ref.value}. 스크립트 파일을 zip 안에 넣고 상대경로로 불러와 주세요.`, from, ref.line);else if (ref.role === 'resource' && /^http:/i.test(ref.value)) add('ref.insecure', `http:// 리소스는 https 페이지에서 막힙니다: ${ref.value}`, from, ref.line);else if (ref.role === 'resource') add('ref.external-request', `zip 밖 리소스를 불러옵니다: ${ref.value}. 막히면 글꼴·이미지가 보이지 않으니 zip 안에 넣어 주세요.`, from, ref.line);
309
+ const font = ref.role === 'resource' && (ref.as === 'style' ? isAllowedExternal(ref.value, 'style-src', spec) : /\.(?:woff2?|ttf|otf|eot)(?:[?#]|$)/i.test(ref.value) && isAllowedExternal(ref.value, 'font-src', spec));
310
+ if (ref.role === 'script') add('ref.external-script', `외부 스크립트를 불러옵니다: ${ref.value}. 스크립트 파일을 zip 안에 넣고 상대경로로 불러와 주세요.`, from, ref.line);else if (ref.role === 'resource' && /^http:/i.test(ref.value)) add('ref.insecure', `http:// 리소스는 https 페이지와 콘텐츠 CSP가 막습니다: ${ref.value}. 파일을 zip 안에 넣고 상대경로로 불러와 주세요.`, from, ref.line);else if (font) add('ref.external-font', `허용 목록의 외부 글꼴을 불러옵니다: ${ref.value}. 망분리 기관에서는 받지 못해 기본 글꼴로 보일 수 있습니다. 꼭 필요한 글꼴이면 zip에 넣어 주세요 (글꼴 파일 또는 CSS data URI).`, from, ref.line);else if (ref.role === 'resource') add('ref.external-request', `zip 밖 리소스를 불러옵니다: ${ref.value}. LXP 콘텐츠 CSP가 외부 이미지 · 글꼴 · 영상 · CSS를 막아 보이지 않습니다. 파일을 zip 안에 넣고 상대경로로 불러와 주세요 (글꼴은 파일 또는 data URI).`, from, ref.line);
261
311
  return;
262
312
  }
263
313
  if (type === 'root') add('ref.root-absolute', `/로 시작하는 경로는 배포 주소에서 깨집니다. 상대경로로 바꿔 주세요: ${ref.value}`, from, ref.line);
@@ -300,18 +350,31 @@ function checkFiles(input, opts = {}) {
300
350
  if (!kindOf || matchExclude(f.path, spec.excluded.dev)) continue;
301
351
  const text = decoder.decode(f.data);
302
352
  const tags = kindOf === 'html' ? parseTags(text) : [];
303
- for (const ref of extractRefs(kindOf, text, tags)) checkRef(f.path, ref);
353
+ const vendor = isVendorFile(f.path);
354
+ // ecdk build가 묶은 모듈 본문(npm 라이브러리 포함)은 원본으로 이미 검사했다 (줄 번호는 그대로)
355
+ const refText = kindOf === 'html' ? blankBundles(text) : text;
356
+ for (const ref of extractRefs(kindOf, refText, tags, {
357
+ jsResources: !vendor
358
+ })) checkRef(f.path, ref);
359
+ if (vendor) {
360
+ const skipVendor = lineSkipper(text);
361
+ const urls = vendorExternalUrls(text, spec).filter(u => !skipVendor.isSkipped(u.line, 'ref.vendor-external-url'));
362
+ const first = urls[0];
363
+ if (first) add('ref.vendor-external-url', `라이브러리 파일에 외부 주소가 있습니다: ${urls.slice(0, 3).map(u => u.url).join(', ')}${urls.length > 3 ? ` 외 ${urls.length - 3}곳` : ''}. 라이브러리가 실행 중 외부(글꼴 · wasm · 지도 타일 · API)를 부르면 LXP 콘텐츠 CSP가 막습니다. ecdk dev로 열어 "막힌 외부 요청" 로그를 확인하고, 필요한 파일은 zip에 넣어 라이브러리 설정으로 상대경로를 주세요.`, f.path, first.line);
364
+ }
304
365
  for (const t of tags) {
305
366
  // <base href>는 그 페이지 모든 상대경로의 기준을 바꾼다. 페이지 자기 폴더(./)만 허용한다:
306
367
  // /·외부 주소·zip 밖(../)은 배포 주소(/s/{서명}/) 밖으로 나가고, 하위 폴더는 참조 검사(파일 위치 기준)와 어긋난다
307
368
  const baseHref = t.name === 'base' ? t.attrs.get('href')?.trim() : undefined;
308
369
  const baseError = baseHref === undefined ? null : baseHrefError(f.path, baseHref);
309
370
  if (baseHref !== undefined && baseError) add('ref.root-absolute', `<base href="${baseHref}">${baseError}`, f.path, t.line);
310
- // LXP는 origin null sandbox에서 열고 파일 서버가 CORS 헤더를 주지 않아, 모듈 스크립트 파일은 받지 못한다
371
+ // 콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없으면 콘텐츠 출처가 null이고 파일 서버가 CORS 헤더를 주지 않아,
372
+ // 모듈 스크립트 파일을 받지 못한다
311
373
  const src = t.name === 'script' ? t.attrs.get('src')?.trim() : undefined;
312
- if (src !== undefined && t.attrs.get('type')?.trim().toLowerCase() === 'module' && classifyRef(src) === 'local' && kind !== 'dir' && !opts.bundlesModules) add('sandbox.module-src', `<script type="module" src="${src}">는 LXP에서 막혀(CORS) 화면이 "불러오는 중"에서 멈춥니다. ecdk build로 만들면 HTML 안에 묶어 넣습니다. 직접 묶으려면 본문을 넣은 <script type="module">이나 일반 <script src>로 바꿔 주세요.`, f.path, t.line);
374
+ if (src !== undefined && t.attrs.get('type')?.trim().toLowerCase() === 'module' && classifyRef(src) === 'local' && kind !== 'dir' && !opts.bundlesModules) add('sandbox.module-src', `<script type="module" src="${src}">는 콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없는 LXP에서 막혀(CORS) 화면이 "불러오는 중"에서 멈춥니다. ecdk build로 만들면 HTML 안에 묶어 넣습니다. 직접 묶으려면 본문을 넣은 <script type="module">이나 일반 <script src>로 바꿔 주세요.`, f.path, t.line);
313
375
  if (t.name === 'img' && !t.attrs.has('alt')) add('html.img-alt', `대체 텍스트(alt)가 없는 이미지입니다.`, f.path, t.line);
314
- if (t.name === 'form') add('html.form', 'form 제출은 sandbox에서 막힙니다. 버튼 click 처리와 SDK 제출을 써 주세요.', f.path, t.line);
376
+ if (FRAME_TAGS.has(t.name) && framesSomething(t)) add('html.iframe', t.name === 'iframe' || t.name === 'frame' ? `<${t.name} src="${t.attrs.get('src')?.trim()}">: 외부 페이지 · 파일을 iframe으로 띄우면 CSP(frame-src 'none')가 막음 (zip 안 파일도). 영상은 Elice 비디오 자료로 따로 올리고, 다른 내용은 이 HTML 안에 넣어 주세요. 코드 미리보기는 srcdoc 사용 가능.` : `<${t.name}>는 LXP 콘텐츠 CSP(object-src 'none')가 막아 빈 칸으로 보입니다. 영상은 Elice 비디오 자료로 따로 올리고, 다른 문서는 내용을 이 HTML 안에 넣어 주세요.`, f.path, t.line);
377
+ if (t.name === 'form') add('html.form', 'form 제출은 sandbox · 콘텐츠 CSP(form-action)가 막습니다. 버튼 click 처리와 SDK 제출을 써 주세요.', f.path, t.line);
315
378
  }
316
379
  if (kindOf === 'css') continue;
317
380
  const skip = lineSkipper(text);
@@ -0,0 +1,26 @@
1
+ import type { RulesSpec } from './types.js';
2
+ /**
3
+ * 운영 콘텐츠 응답 CSP 초안 (서버 수정 제안 1번, https://artifacts.dev.elicer.io/a/MXvtD5dojpit).
4
+ * 서버 CSP가 확정되면 이 목록을 맞춘다. `ecdk dev` 콘텐츠 서버가 이 값으로 응답하고, CLI README가 같은 글을 보인다
5
+ * (`docs.test.ts`가 대조). 허용 외부 출처는 rules.json `externalAllow` 한 곳에서 해당 지시어에 더한다.
6
+ * - sandbox는 `allow-same-origin`까지 (LXP iframe 속성과 같게, 콘텐츠는 제 하위 도메인 출처로 돈다)
7
+ * - `'self'` 대신 호스트를 직접 적는다 (헤더에 allow-same-origin이 없는 서버에서는 출처가 null이라 'self' 해석이 브라우저마다 다를 수 있음)
8
+ * - `webrtc 'block'`은 지원하는 브라우저에서만 (모르는 브라우저는 무시)
9
+ */
10
+ export declare const CONTENT_CSP: readonly (readonly [string, ...string[]])[];
11
+ export interface CspValues {
12
+ /** 콘텐츠를 내주는 출처 (dev: http://127.0.0.1:<포트+1>) */
13
+ contentHost: string;
14
+ /** SDK가 부르는 material API 출처 (dev: 흉내 서버 http://localhost:<포트>) */
15
+ materialApi: string;
16
+ /** 콘텐츠를 iframe으로 띄우는 LXP 출처 (dev: 흉내 화면 http://localhost:<포트>) */
17
+ lxpOrigins: string;
18
+ }
19
+ /** 콘텐츠 CSP 헤더 값. values가 없으면 자리표시({CONTENT_HOST} 등) 그대로 (문서용) */
20
+ export declare function contentCsp(values?: CspValues, spec?: RulesSpec): string;
21
+ /**
22
+ * 외부 주소가 rules.json `externalAllow`의 그 지시어 출처인지. `//host`(프로토콜 생략)는 https로 본다
23
+ */
24
+ export declare function isAllowedExternal(url: string, directive: keyof NonNullable<RulesSpec['externalAllow']>, spec?: RulesSpec): boolean;
25
+ /** 허용 목록의 모든 출처 (라이브러리 외부 주소 경고에서 뺄 때) */
26
+ export declare function allowedOrigins(spec?: RulesSpec): string[];
@@ -0,0 +1,42 @@
1
+ import { rules } from './spec.js';
2
+
3
+ /**
4
+ * 운영 콘텐츠 응답 CSP 초안 (서버 수정 제안 1번, https://artifacts.dev.elicer.io/a/MXvtD5dojpit).
5
+ * 서버 CSP가 확정되면 이 목록을 맞춘다. `ecdk dev` 콘텐츠 서버가 이 값으로 응답하고, CLI README가 같은 글을 보인다
6
+ * (`docs.test.ts`가 대조). 허용 외부 출처는 rules.json `externalAllow` 한 곳에서 해당 지시어에 더한다.
7
+ * - sandbox는 `allow-same-origin`까지 (LXP iframe 속성과 같게, 콘텐츠는 제 하위 도메인 출처로 돈다)
8
+ * - `'self'` 대신 호스트를 직접 적는다 (헤더에 allow-same-origin이 없는 서버에서는 출처가 null이라 'self' 해석이 브라우저마다 다를 수 있음)
9
+ * - `webrtc 'block'`은 지원하는 브라우저에서만 (모르는 브라우저는 무시)
10
+ */
11
+ const CONTENT_CSP = [['sandbox', 'allow-scripts', 'allow-same-origin'], ['default-src', "'none'"], ['script-src', '{CONTENT_HOST}', "'unsafe-inline'", "'unsafe-eval'", 'blob:'], ['style-src', '{CONTENT_HOST}', "'unsafe-inline'"], ['img-src', '{CONTENT_HOST}', 'data:', 'blob:'], ['font-src', '{CONTENT_HOST}', 'data:'], ['media-src', '{CONTENT_HOST}', 'data:', 'blob:'], ['connect-src', '{MATERIAL_API}'], ['worker-src', 'blob:'], ['frame-src', "'none'"], ['form-action', "'none'"], ['object-src', "'none'"], ['base-uri', '{CONTENT_HOST}'], ['webrtc', "'block'"], ['frame-ancestors', '{LXP_ORIGINS}']];
12
+ /** 콘텐츠 CSP 헤더 값. values가 없으면 자리표시({CONTENT_HOST} 등) 그대로 (문서용) */
13
+ function contentCsp(values, spec = rules) {
14
+ const fill = values ? {
15
+ '{CONTENT_HOST}': values.contentHost,
16
+ '{MATERIAL_API}': values.materialApi,
17
+ '{LXP_ORIGINS}': values.lxpOrigins
18
+ } : {};
19
+ const allow = spec.externalAllow ?? {};
20
+ return CONTENT_CSP.map(([name, ...sources]) => {
21
+ const extra = allow[name] ?? [];
22
+ return [name, ...sources.map(s => fill[s] ?? s), ...extra].join(' ');
23
+ }).join('; ');
24
+ }
25
+ /**
26
+ * 외부 주소가 rules.json `externalAllow`의 그 지시어 출처인지. `//host`(프로토콜 생략)는 https로 본다
27
+ */
28
+ function isAllowedExternal(url, directive, spec = rules) {
29
+ const list = spec.externalAllow?.[directive] ?? [];
30
+ try {
31
+ const origin = new URL(url.startsWith('//') ? `https:${url}` : url).origin;
32
+ return list.includes(origin);
33
+ } catch {
34
+ return false;
35
+ }
36
+ }
37
+ /** 허용 목록의 모든 출처 (라이브러리 외부 주소 경고에서 뺄 때) */
38
+ function allowedOrigins(spec = rules) {
39
+ return Object.values(spec.externalAllow ?? {}).flat();
40
+ }
41
+
42
+ export { CONTENT_CSP, allowedOrigins, contentCsp, isAllowedExternal };
@@ -1,4 +1,5 @@
1
1
  export { checkFiles } from './check.js';
2
+ export { allowedOrigins, CONTENT_CSP, contentCsp, type CspValues, isAllowedExternal, } from './csp.js';
2
3
  export { COMPLETION_POLICIES_IGNORED, graderTypeError, LEGACY_COMPLETION_FIELDS, LEGACY_COMPLETION_SCREENS, type ManifestWarning, parseManifest, serializeManifest, stripCompletionPolicy, } from './manifest.js';
3
4
  export { globToRegExp } from './path.js';
4
5
  export { commentOnlyLines, lineSkipper } from './skip.js';
package/es/rules/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { checkFiles } from './check.js';
2
+ export { CONTENT_CSP, allowedOrigins, contentCsp, isAllowedExternal } from './csp.js';
2
3
  export { COMPLETION_POLICIES_IGNORED, LEGACY_COMPLETION_FIELDS, LEGACY_COMPLETION_SCREENS, graderTypeError, parseManifest, serializeManifest, stripCompletionPolicy } from './manifest.js';
3
4
  export { globToRegExp } from './path.js';
4
5
  export { commentOnlyLines, lineSkipper } from './skip.js';
@@ -4,16 +4,26 @@ export interface Ref {
4
4
  value: string;
5
5
  line: number;
6
6
  role: RefRole;
7
+ /** 스타일시트로 불러옴 (`<link rel="stylesheet">` · CSS `@import`): CSP style-src 허용 목록과 비교 */
8
+ as?: 'style';
7
9
  }
8
10
  export interface HtmlTag {
9
11
  name: string;
10
12
  attrs: Map<string, string>;
11
13
  line: number;
12
14
  }
15
+ /** 다른 문서를 안에 띄우는 태그: 외부 주소는 html.iframe이 따로 알린다 (안 파일은 ref.missing만 봄) */
16
+ export declare const FRAME_TAGS: Set<string>;
13
17
  declare function lineAt(text: string, index: number): number;
14
18
  export declare function parseTags(html: string): HtmlTag[];
15
- /** HTML 태그 속성, CSS url()·@import, JS 정적·동적 import의 문자열 리터럴 참조. 스크립트가 만든 경로(fetch 등)는 못 잡는다. */
16
- export declare function extractRefs(kind: 'html' | 'css' | 'js', text: string, tags?: HtmlTag[]): Ref[];
19
+ /**
20
+ * HTML 태그 속성, CSS url()·@import, JS 정적·동적 import의 문자열 리터럴 참조, JS가 외부 리소스를 넣는 흔한 모양
21
+ * (JS_RESOURCE, 외부 주소만). 스크립트가 만든 경로(fetch 등)는 못 잡는다.
22
+ * `jsResources: false`: 라이브러리 파일은 외부 리소스 모양을 보지 않는다 (ref.vendor-external-url 경고가 맡음)
23
+ */
24
+ export declare function extractRefs(kind: 'html' | 'css' | 'js', text: string, tags?: HtmlTag[], { jsResources }?: {
25
+ jsResources?: boolean | undefined;
26
+ }): Ref[];
17
27
  export type RefKind = 'local' | 'root' | 'external' | 'skip';
18
28
  export declare function classifyRef(value: string): RefKind;
19
29
  export { lineAt };
package/es/rules/refs.js CHANGED
@@ -1,23 +1,41 @@
1
1
  const TAG = /<([a-zA-Z][\w-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g;
2
2
  const ATTR = /([^\s"'=<>/]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g;
3
3
  const RAW_BLOCK = /<(script|style)\b[^>]*>([\s\S]*?)<\/\1\s*>/gi;
4
- const CSS_URL = /url\(\s*(?:"([^"]*)"|'([^']*)'|([^)'"\s]+))\s*\)|@import\s+(?:"([^"]*)"|'([^']*)')/g;
4
+ const CSS_URL = /(?<!@import\s*)url\(\s*(?:"([^"]*)"|'([^']*)'|([^)'"\s]+))\s*\)/g;
5
+ const CSS_IMPORT = /@import\s+(?:url\(\s*)?(?:"([^"]*)"|'([^']*)'|([^)'"\s;]+))/g;
6
+ /**
7
+ * JS가 외부 리소스를 불러오는 흔한 모양 (외부 주소만): `.src = 'https://…'` · `setAttribute('src', 'https://…')` ·
8
+ * `new Audio('https://…')` · 문자열 안 CSS `url(https://…)`. 이동 링크(`.href`)와 fetch(api.external-send)는 뺀다
9
+ */
10
+ const JS_RESOURCE = /(?:\.(?:src|poster)\s*=\s*|\bsetAttribute\(\s*['"](?:src|poster)['"]\s*,\s*|\bnew\s+Audio\(\s*)['"`]((?:https?:)?\/\/[^'"`\s]+)|\burl\(\s*['"]?((?:https?:)?\/\/[^'"`\s)]+)/g;
11
+ /** 다른 문서를 안에 띄우는 태그: 외부 주소는 html.iframe이 따로 알린다 (안 파일은 ref.missing만 봄) */
12
+ const FRAME_TAGS = new Set(['iframe', 'frame', 'object', 'embed']);
13
+ /** `<link rel>` 중 연결만 미리 여는 힌트 (리소스를 받지 않음) */
14
+ const CONNECTION_HINTS = new Set(['preconnect', 'dns-prefetch']);
5
15
  const JS_IMPORT = /\b(?:import|export)\b[^'"`;]*?\bfrom\s*(?:"([^"]*)"|'([^']*)')|\bimport\s+(?:"([^"]*)"|'([^']*)')|\bimport\s*\(\s*(?:"([^"]*)"|'([^']*)')\s*\)/g;
6
16
  function lineAt(text, index) {
7
17
  let n = 1;
8
18
  for (let i = 0; i < index; i++) if (text.charCodeAt(i) === 10) n++;
9
19
  return n;
10
20
  }
11
- function collect(text, re, role, out, lineBase = 0) {
21
+ function collect(text, re, role, out, lineBase = 0, as) {
12
22
  for (const m of text.matchAll(re)) {
13
23
  const raw = m.slice(1).find(g => g !== undefined);
14
24
  if (raw !== undefined) out.push({
15
25
  value: raw.trim(),
16
26
  line: lineAt(text, m.index) + lineBase,
17
- role
27
+ role,
28
+ ...(as ? {
29
+ as
30
+ } : {})
18
31
  });
19
32
  }
20
33
  }
34
+ /** CSS의 url() · @import */
35
+ function cssRefs(text, out, lineBase = 0) {
36
+ collect(text, CSS_URL, 'resource', out, lineBase);
37
+ collect(text, CSS_IMPORT, 'resource', out, lineBase, 'style');
38
+ }
21
39
  /** <script>·<style> 본문을 같은 줄 수의 빈 칸으로 바꾼다. 스크립트 안의 `a<b` 같은 글자를 태그로 읽지 않도록. */
22
40
  function blankRawBlocks(html) {
23
41
  return html.replace(RAW_BLOCK, (all, _tag, body) => all.replace(body, body.replace(/[^\n]/g, ' ')));
@@ -41,10 +59,13 @@ function parseTags(html) {
41
59
  const RESOURCE_ATTRS = ['src', 'poster', 'data'];
42
60
  function tagRefs(tags, out) {
43
61
  for (const t of tags) {
44
- const push = (value, role) => out.push({
62
+ const push = (value, role, as) => out.push({
45
63
  value: value.trim(),
46
64
  line: t.line,
47
- role
65
+ role,
66
+ ...(as ? {
67
+ as
68
+ } : {})
48
69
  });
49
70
  if (t.name === 'script') {
50
71
  const src = t.attrs.get('src');
@@ -55,12 +76,15 @@ function tagRefs(tags, out) {
55
76
  if (href !== undefined) {
56
77
  if (t.name === 'a' || t.name === 'area') push(href, 'link');else if (t.name === 'link') {
57
78
  const rel = t.attrs.get('rel') ?? '';
58
- push(href, /\bmodulepreload\b/i.test(rel) ? 'script' : 'resource');
79
+ const rels = rel.toLowerCase().split(/\s+/).filter(Boolean);
80
+ // 연결 힌트(preconnect · dns-prefetch)는 리소스를 받지 않는다: 참조로 보지 않음 (Google Fonts 스니펫 등)
81
+ if (rels.length > 0 && rels.every(r => CONNECTION_HINTS.has(r))) continue;
82
+ if (/\bmodulepreload\b/i.test(rel)) push(href, 'script');else push(href, 'resource', /\bstylesheet\b/i.test(rel) ? 'style' : undefined);
59
83
  }
60
84
  }
61
85
  for (const a of RESOURCE_ATTRS) {
62
86
  const v = t.attrs.get(a);
63
- if (v !== undefined) push(v, 'resource');
87
+ if (v !== undefined) push(v, FRAME_TAGS.has(t.name) ? 'link' : 'resource');
64
88
  }
65
89
  const srcset = t.attrs.get('srcset');
66
90
  if (srcset !== undefined) {
@@ -69,7 +93,7 @@ function tagRefs(tags, out) {
69
93
  const style = t.attrs.get('style');
70
94
  if (style !== undefined) {
71
95
  const inner = [];
72
- collect(style, CSS_URL, 'resource', inner);
96
+ cssRefs(style, inner);
73
97
  out.push(...inner.map(r => ({
74
98
  ...r,
75
99
  line: t.line
@@ -77,28 +101,36 @@ function tagRefs(tags, out) {
77
101
  }
78
102
  }
79
103
  }
80
- /** HTML 태그 속성, CSS url()·@import, JS 정적·동적 import의 문자열 리터럴 참조. 스크립트가 만든 경로(fetch 등)는 못 잡는다. */
81
- function extractRefs(kind, text, tags) {
104
+ /**
105
+ * HTML 태그 속성, CSS url()·@import, JS 정적·동적 import의 문자열 리터럴 참조, JS가 외부 리소스를 넣는 흔한 모양
106
+ * (JS_RESOURCE, 외부 주소만). 스크립트가 만든 경로(fetch 등)는 못 잡는다.
107
+ * `jsResources: false`: 라이브러리 파일은 외부 리소스 모양을 보지 않는다 (ref.vendor-external-url 경고가 맡음)
108
+ */
109
+ function extractRefs(kind, text, tags, {
110
+ jsResources = true
111
+ } = {}) {
82
112
  const out = [];
83
113
  if (kind === 'css') {
84
- collect(text, CSS_URL, 'resource', out);
114
+ cssRefs(text, out);
85
115
  return out;
86
116
  }
87
- if (kind === 'js') return jsRefs(text, 0);
117
+ if (kind === 'js') return jsRefs(text, 0, jsResources);
88
118
  tagRefs(tags ?? parseTags(text), out);
89
119
  for (const m of text.matchAll(RAW_BLOCK)) {
90
120
  const [all, tag, body] = m;
91
121
  if (body === undefined) continue;
92
122
  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));
123
+ if (tag?.toLowerCase() === 'style') cssRefs(body, out, base);else out.push(...jsRefs(body, base, jsResources));
94
124
  }
95
125
  return out;
96
126
  }
97
127
  /** 상대경로와 외부 주소 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));
128
+ function jsRefs(text, lineBase, resources = true) {
129
+ const imports = [];
130
+ collect(text, JS_IMPORT, 'script', imports, lineBase);
131
+ const out = imports.filter(r => /^(?:\.{0,2}\/|https?:)/i.test(r.value));
132
+ if (resources) collect(text, JS_RESOURCE, 'resource', out, lineBase);
133
+ return out;
102
134
  }
103
135
  function classifyRef(value) {
104
136
  if (value === '' || value.startsWith('#') || value.includes('{{') || value.includes('${')) return 'skip';
@@ -108,4 +140,4 @@ function classifyRef(value) {
108
140
  return 'local';
109
141
  }
110
142
 
111
- export { classifyRef, extractRefs, lineAt, parseTags };
143
+ export { FRAME_TAGS, classifyRef, extractRefs, lineAt, parseTags };
@@ -63,6 +63,11 @@ export interface RulesSpec {
63
63
  minVersions: {
64
64
  sdk: string;
65
65
  };
66
+ /**
67
+ * 콘텐츠 CSP가 허용하는 외부 출처 (지시어 → 출처 목록, 서버 CSP 허용 목록과 같게 유지). 검사는 여기 있는 출처를
68
+ * 오류(ref.external-request) 대신 경고(ref.external-font)로, `ecdk dev`는 CSP 해당 지시어에 더한다 (csp.ts)
69
+ */
70
+ externalAllow?: Partial<Record<'style-src' | 'font-src', string[]>>;
66
71
  }
67
72
  /**
68
73
  * 비밀 값 탐지 (`sec.secret`). 사내 SAST(semgrep p/secrets + security/semgrep custom)를 옮긴 것.
package/es/rules.json.js CHANGED
@@ -1,3 +1,3 @@
1
- const version="0.9.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 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:"쿠키 사용 (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 대상이 * (아무 창이나 받을 수 있음)"},{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로 읽음 (LXP sandbox에서 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:"warn",scope:"client",title:"외부 리소스 요청 (글꼴·이미지 등이 막힐 수 있음)"},{id:"ref.insecure",level:"warn",scope:"client",title:"http:// 외부 리소스 (https 페이지에서 막힘)"},{id:"sandbox.module-src",level:"error",scope:"client",title:"모듈 스크립트 파일(<script type=\"module\" src>): LXP sandbox에서 CORS로 막혀 화면이 뜨지 않음 (ecdk build가 HTML 안에 묶음)"},{id:"sandbox.fetch-local",level:"error",scope:"client",title:"zip 안 파일을 fetch · 변수 import() · Worker로 읽음: LXP sandbox에서 CORS로 막힘 (JSON fetch · 문자열 import()는 ecdk build가 처리)"},{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 대상 *"},{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:"warn",scope:"client",title:"옛 lib/cdk.js 복사본 (package.json에 @eliceio/cdk가 없음, 프로젝트 검사만. SDK를 package.json 의존성으로 옮기기)"}];var rulesJson = {version:version,manifest:manifest,minVersions:minVersions,limits:limits,allowedExtensions:allowedExtensions,imageExtensions:imageExtensions,excluded:excluded,forbiddenApis:forbiddenApis,secretPatterns:secretPatterns,rules:rules};
1
+ const version="0.11.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:"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:"warn",scope:"client",title:"옛 lib/cdk.js 복사본 (package.json에 @eliceio/cdk가 없음, 프로젝트 검사만. SDK를 package.json 의존성으로 옮기기)"}];var rulesJson = {version:version,manifest:manifest,externalAllow:externalAllow,minVersions:minVersions,limits:limits,allowedExtensions:allowedExtensions,imageExtensions:imageExtensions,excluded:excluded,forbiddenApis:forbiddenApis,secretPatterns:secretPatterns,rules:rules};
2
2
 
3
- export { allowedExtensions, rulesJson as default, excluded, forbiddenApis, imageExtensions, limits, manifest, minVersions, rules, secretPatterns, version };
3
+ export { allowedExtensions, rulesJson as default, excluded, externalAllow, forbiddenApis, imageExtensions, limits, manifest, minVersions, rules, secretPatterns, version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eliceio/cdk-cli",
3
- "version": "0.1.0-alpha.5",
3
+ "version": "0.1.0-alpha.6",
4
4
  "description": "교육자용 Custom HTML 콘텐츠 CLI",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -40,7 +40,7 @@
40
40
  "rollup": "^4.0.0",
41
41
  "tslib": "^2.6.1",
42
42
  "typescript": "~5.9.3",
43
- "@eliceio/cdk": "^1.0.0-alpha.5"
43
+ "@eliceio/cdk": "^1.0.0-alpha.6"
44
44
  },
45
45
  "scripts": {
46
46
  "prebuild": "del-cli \"buildcache/*\" \"es/*\"",
package/rules.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.9.0",
2
+ "version": "0.11.0",
3
3
  "manifest": {
4
4
  "file": "metadata.json",
5
5
  "kinds": ["material", "description"],
@@ -14,6 +14,10 @@
14
14
  "commentaryFile": "commentary.txt",
15
15
  "defaultEntry": "index.html"
16
16
  },
17
+ "externalAllow": {
18
+ "style-src": [],
19
+ "font-src": []
20
+ },
17
21
  "minVersions": {
18
22
  "sdk": "1.0.0-alpha.4"
19
23
  },
@@ -90,12 +94,12 @@
90
94
  {
91
95
  "id": "api.cookie",
92
96
  "pattern": "\\bdocument\\.cookie\\b",
93
- "title": "쿠키 사용 (sandbox에서 예외가 남)"
97
+ "title": "쿠키 사용 (이 브라우저에만 남고 학습 기록이 아님, 남길 입력값은 SDK로 저장)"
94
98
  },
95
99
  {
96
100
  "id": "api.storage",
97
101
  "pattern": "\\b(?:localStorage|sessionStorage|indexedDB)\\b",
98
- "title": "브라우저 저장소 사용 (sandbox에서 예외가 남, 입력값 저장은 SDK 사용)"
102
+ "title": "브라우저 저장소 사용 (이 브라우저 · 기기에만 남고 학습 기록이 아님, 남길 입력값은 SDK로 저장)"
99
103
  },
100
104
  {
101
105
  "id": "api.eval",
@@ -135,7 +139,7 @@
135
139
  {
136
140
  "id": "sandbox.fetch-local",
137
141
  "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+.-]*:|//)",
138
- "title": "zip 안 파일을 fetch · 변수 import() · Worker로 읽음 (LXP sandbox에서 CORS로 막힘)"
142
+ "title": "zip 안 파일을 fetch · 변수 import() · Worker로 읽음 (콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없으면 CORS로 막힘)"
139
143
  }
140
144
  ],
141
145
  "secretPatterns": [
@@ -531,27 +535,39 @@
531
535
  },
532
536
  {
533
537
  "id": "ref.external-request",
538
+ "level": "error",
539
+ "scope": "client",
540
+ "title": "외부 리소스 요청 (이미지 · 글꼴 · 영상 · CSS, 콘텐츠 CSP가 막음: zip 안에 넣기)"
541
+ },
542
+ {
543
+ "id": "ref.external-font",
534
544
  "level": "warn",
535
545
  "scope": "client",
536
- "title": "외부 리소스 요청 (글꼴·이미지 등이 막힐 수 있음)"
546
+ "title": "허용 목록(externalAllow)의 외부 글꼴 (망분리 기관에서는 받지 못해 기본 글꼴로 보일 수 있음)"
537
547
  },
538
548
  {
539
549
  "id": "ref.insecure",
550
+ "level": "error",
551
+ "scope": "client",
552
+ "title": "http:// 외부 리소스 (https 페이지 · 콘텐츠 CSP가 막음)"
553
+ },
554
+ {
555
+ "id": "ref.vendor-external-url",
540
556
  "level": "warn",
541
557
  "scope": "client",
542
- "title": "http:// 외부 리소스 (https 페이지에서 막힘)"
558
+ "title": "라이브러리 파일 안의 외부 주소 (실행 중 외부를 부르면 콘텐츠 CSP가 막음, ecdk dev 로그 확인)"
543
559
  },
544
560
  {
545
561
  "id": "sandbox.module-src",
546
- "level": "error",
562
+ "level": "warn",
547
563
  "scope": "client",
548
- "title": "모듈 스크립트 파일(<script type=\"module\" src>): LXP sandbox에서 CORS로 막혀 화면이 뜨지 않음 (ecdk build가 HTML 안에 묶음)"
564
+ "title": "모듈 스크립트 파일(<script type=\"module\" src>): 콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없는 LXP에서는 CORS로 막혀 화면이 뜨지 않음 (ecdk build가 HTML 안에 묶음)"
549
565
  },
550
566
  {
551
567
  "id": "sandbox.fetch-local",
552
- "level": "error",
568
+ "level": "warn",
553
569
  "scope": "client",
554
- "title": "zip 안 파일을 fetch · 변수 import() · Worker로 읽음: LXP sandbox에서 CORS로 막힘 (JSON fetch · 문자열 import()는 ecdk build가 처리)"
570
+ "title": "zip 안 파일을 fetch · 변수 import() · Worker로 읽음: 콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없는 LXP에서는 CORS로 막힘 (JSON fetch · 문자열 import()는 ecdk build가 처리)"
555
571
  },
556
572
  {
557
573
  "id": "html.img-alt",
@@ -559,11 +575,17 @@
559
575
  "scope": "client",
560
576
  "title": "대체 텍스트 없는 이미지"
561
577
  },
578
+ {
579
+ "id": "html.iframe",
580
+ "level": "error",
581
+ "scope": "client",
582
+ "title": "src로 띄우는 iframe · frame, object · embed (콘텐츠 CSP가 막음, 영상은 Elice 비디오 자료로, srcdoc 미리보기는 통과)"
583
+ },
562
584
  {
563
585
  "id": "html.form",
564
586
  "level": "warn",
565
587
  "scope": "client",
566
- "title": "form 제출 (sandbox에서 막힘, 버튼 click으로 처리)"
588
+ "title": "form 제출 (sandbox · CSP form-action이 막음, 버튼 click으로 처리)"
567
589
  },
568
590
  {
569
591
  "id": "api.external-send",
@@ -579,15 +601,15 @@
579
601
  },
580
602
  {
581
603
  "id": "api.cookie",
582
- "level": "error",
604
+ "level": "warn",
583
605
  "scope": "client",
584
- "title": "쿠키 사용"
606
+ "title": "쿠키 사용 (학습 기록이 아님)"
585
607
  },
586
608
  {
587
609
  "id": "api.storage",
588
- "level": "error",
610
+ "level": "warn",
589
611
  "scope": "client",
590
- "title": "브라우저 저장소 사용"
612
+ "title": "브라우저 저장소 사용 (학습 기록이 아님)"
591
613
  },
592
614
  {
593
615
  "id": "api.eval",