ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / extensions / aura-team / test / archives-rules.test.mjs 101 строк · изменён 14 нояб., 04:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { strict as assert } from 'node:assert' ;
import { readFileSync } from 'node:fs' ;
import { fileURLToPath } from 'node:url' ;
import { dirname, join } from 'node:path' ;
import vm from 'node:vm' ;
import ts from 'typescript' ;
const here = dirname ( fileURLToPath ( import . meta . url )
root here
checks
failures
checks
error failures name error
assert value message
assert actual expected message
source root relativePath
out ts source ts ts
sandbox
sandbox sandbox
vm out sandbox relativePath
sandbox
rules
disposition
name rules name
name rules name
rules
rules
rules
rules
rules
rules
rules
rules
rules
header
disposition header
header
disposition header
disposition
disposition
disposition
disposition
disposition
disposition
disposition
disposition
disposition
disposition
failures process
)
;
const
=
join
(
,
'..'
)
;
let
=
0
;
let
=
0
;
function
check
(
name, fn
)
{
++
;
try
{
fn
(
)
;
}
catch
(
)
{
++
;
console
.
error
(
'FAIL '
+
+
'\n '
+
.
message
)
;
}
}
function
ok
(
value, message
)
{
.
ok
(
,
)
;
}
function
eq
(
actual, expected, message
)
{
.
equal
(
,
,
??
` expected ${ expected} , got ${ actual} `
)
;
}
function
loadModule
(
relativePath
)
{
const
=
readFileSync
(
join
(
,
)
,
'utf8'
)
;
const
=
.
transpileModule
(
,
{
compilerOptions
:
{
module
:
.
ModuleKind
.
CommonJS
,
target
:
.
ScriptTarget
.
ES2022
}
}
)
.
outputText
;
const
=
{
module
:
{
exports
:
{
}
}
,
exports
:
{
}
,
require
:
(
)
=>
{
throw
new
Error
(
'unexpected require'
)
;
}
}
;
.
exports
=
.
module
.
exports
;
.
runInNewContext
(
,
,
{
filename
:
}
)
;
return
.
module
.
exports
;
}
const
=
loadModule
(
'src/archives/rules.ts'
)
;
const
=
loadModule
(
'src/api/disposition.ts'
)
;
check
(
'принимаем .zip и .rar в любом регистре'
,
(
)
=>
{
for
(
const
of
[
'project.zip'
,
'PROJECT.RAR'
,
'a.b.zip'
,
'архив.zip'
]
)
{
ok
(
.
isArchiveName
(
)
,
` не принято: ${ name} `
)
;
}
}
)
;
check
(
'не принимаем прочие файлы'
,
(
)
=>
{
for
(
const
of
[
'project.tar.gz'
,
'notes.txt'
,
'zip'
,
'project.zip.exe'
,
''
,
undefined
,
null
]
)
{
ok
(
!
.
isArchiveName
(
)
,
` принято зря: ${ String ( name) } `
)
;
}
}
)
;
check
(
'лимит печатается в человеческих единицах'
,
(
)
=>
{
eq
(
.
humanBytes
(
1024
*
1024
*
1024
)
,
'1 GiB'
)
;
eq
(
.
humanBytes
(
512
*
1024
*
1024
)
,
'512 MiB'
)
;
eq
(
.
humanBytes
(
2048
)
,
'2 KiB'
)
;
eq
(
.
humanBytes
(
0
)
,
'0 B'
)
;
}
)
;
check
(
'имя для диалога сохраняет расширение из серверного имени'
,
(
)
=>
{
eq
(
.
suggestedArchiveName
(
'Соцсети'
,
'архив.rar'
)
,
'Соцсети.rar'
)
;
eq
(
.
suggestedArchiveName
(
'Social services application'
,
'проект.zip'
)
,
'Social services application.zip'
)
;
}
)
;
check
(
'имя для диалога санитизирует запрещённые в путях символы'
,
(
)
=>
{
eq
(
.
suggestedArchiveName
(
'a/b:c*d?e"f<g>h|i'
,
'x.zip'
)
,
'a_b_c_d_e_f_g_h_i.zip'
)
;
eq
(
.
suggestedArchiveName
(
''
,
'fallback.rar'
)
,
'fallback.rar'
)
;
eq
(
.
suggestedArchiveName
(
undefined
,
undefined
)
,
'archive.zip'
)
;
}
)
;
check
(
'RFC 5987: читаем filename* с кириллицей'
,
(
)
=>
{
const
=
` attachment; filename="proekt.zip"; filename*=UTF-8'' ${ encodeURIComponent ( 'Проект команды.zip' ) } `
;
eq
(
.
fileNameFromDisposition
(
)
,
'Проект команды.zip'
)
;
}
)
;
check
(
'RFC 5987: язык в filename* игнорируется'
,
(
)
=>
{
const
=
` attachment; filename*=UTF-8'en' ${ encodeURIComponent ( 'report final.zip' ) } `
;
eq
(
.
fileNameFromDisposition
(
)
,
'report final.zip'
)
;
}
)
;
check
(
'фолбэк на простой filename'
,
(
)
=>
{
eq
(
.
fileNameFromDisposition
(
'attachment; filename="release.zip"'
)
,
'release.zip'
)
;
eq
(
.
fileNameFromDisposition
(
'attachment; filename=release.zip'
)
,
'release.zip'
)
;
}
)
;
check
(
'без заголовка — фолбэк по умолчанию'
,
(
)
=>
{
eq
(
.
fileNameFromDisposition
(
undefined
)
,
'archive'
)
;
eq
(
.
fileNameFromDisposition
(
''
,
'archive.zip'
)
,
'archive.zip'
)
;
eq
(
.
fileNameFromDisposition
(
'attachment'
)
,
'archive'
)
;
}
)
;
check
(
'битый percent-encoding не роняет скачивание'
,
(
)
=>
{
eq
(
.
fileNameFromDisposition
(
` attachment; filename*=UTF-8''%E0%A4%A `
)
,
'archive'
)
;
}
)
;
check
(
'имя не может съехать в путь'
,
(
)
=>
{
eq
(
.
fileNameFromDisposition
(
'attachment; filename="../../etc/passwd.zip"'
)
,
'.._.._etc_passwd.zip'
)
;
eq
(
.
fileNameFromDisposition
(
'attachment; filename="a\\b.zip"'
)
,
'a_b.zip'
)
;
}
)
;
check
(
'управляющие символы вырезаются'
,
(
)
=>
{
eq
(
.
fileNameFromDisposition
(
'attachment; filename="a\u0000b.zip"'
)
,
'ab.zip'
)
;
}
)
;
check
(
'очень длинное имя обрезается'
,
(
)
=>
{
ok
(
.
fileNameFromDisposition
(
'attachment; filename="'
+
'x'
.
repeat
(
400
)
+
'.zip"'
)
.
length
<=
180
,
'имя не обрезано'
)
;
}
)
;
console
.
log
(
` ${ checks - failures} / ${ checks} проверок архивных правил `
)
;
if
(
)
{
.
exit
(
1
)
;
}