Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
gstack/test/artifacts-allowlist-decisions.test.ts at main · garrytan/gstack · GitHub
Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
garrytan
gstack
Repository navigation
Code
Issues
160
(160)
Pull requests
49
(49)
Actions
Projects
Security and quality
1
(1)
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
gstack
/
test
/
artifacts-allowlist-decisions.test.ts
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
66 lines (58 loc) · 2.87 KB
main
Breadcrumbs
gstack
/
test
/
artifacts-allowlist-decisions.test.ts
Copy path
Top
File metadata and controls
Code
Blame
66 lines (58 loc) · 2.87 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
{
describe
,
test
,
expect
}
from
"bun:test"
;
import
*
as
fs
from
"fs"
;
import
*
as
path
from
"path"
;
const
ROOT
=
path
.
resolve
(
import
.
meta
.
dir
,
".."
)
;
const
INIT
=
fs
.
readFileSync
(
path
.
join
(
ROOT
,
"bin"
,
"gstack-artifacts-init"
)
,
"utf-8"
)
;
/** Pull a quoted heredoc body out of gstack-artifacts-init by destination. */
function
heredoc
(
target
:
string
)
:
string
{
const
re
=
new
RegExp
(
`cat > "
${
target
}
" <<'EOF'\\n([\\s\\S]*?)\\nEOF\\n`
)
;
const
m
=
INIT
.
match
(
re
)
;
if
(
!
m
)
throw
new
Error
(
`heredoc for
${
target
}
not found in gstack-artifacts-init`
)
;
return
m
[
1
]
;
}
/** fnmatch.fnmatchcase semantics, as compute_paths_to_stage applies them:
* `*` does not cross a path separator. */
function
globToRe
(
g
:
string
)
:
RegExp
{
return
new
RegExp
(
"^"
+
g
.
split
(
"*"
)
.
map
(
(
s
)
=>
s
.
replace
(
/
[
.
]
/
g
,
"[.]"
)
)
.
join
(
"[^/]*"
)
+
"$"
)
;
}
const
DECISION_PATHS
=
[
"projects/acme-widget/decisions.jsonl"
,
"projects/acme-widget/decisions.active.json"
,
"projects/acme-widget/decisions.archive.jsonl"
,
]
;
/**
* gstack-decision-log:40 enqueues projects/<slug>/decisions.jsonl after EVERY write,
* but no managed glob matched it, so compute_paths_to_stage rejected all of them at
* its "must match at least one allowlist glob" check. The writer and the syncer
* disagreed silently: turning artifacts sync on backed up learnings, plans, designs
* and timelines -- everything EXCEPT the durable decision ledger -- and nothing
* anywhere reported a miss, because a dropped path prints exactly what a synced one
* does when the queue is otherwise empty.
*
* Source-level rather than end-to-end: gstack-artifacts-init.test.ts drives the real
* script through #!/bin/bash shims and a colon-separated PATH, so it cannot run on
* Windows -- which is the platform where this bug bit.
*/
describe
(
"the artifacts allowlist covers the decision store"
,
(
)
=>
{
const
globs
=
heredoc
(
"\\$ALLOWLIST_TMP"
)
.
split
(
"\n"
)
.
map
(
(
l
)
=>
l
.
trim
(
)
)
.
filter
(
(
l
)
=>
l
&&
!
l
.
startsWith
(
"#"
)
)
;
test
(
"every decisions.* path matches at least one allowlist glob"
,
(
)
=>
{
for
(
const
p
of
DECISION_PATHS
)
{
expect
(
{
p
,
matched
:
globs
.
some
(
(
g
)
=>
globToRe
(
g
)
.
test
(
p
)
)
}
)
.
toEqual
(
{
p
,
matched
:
true
}
)
;
}
}
)
;
test
(
"decisions.* are class artifact, so they sync in artifacts-only mode too"
,
(
)
=>
{
const
map
=
JSON
.
parse
(
heredoc
(
"\\$GSTACK_HOME/\\.brain-privacy-map\\.json"
)
)
;
for
(
const
p
of
DECISION_PATHS
)
{
const
hit
=
map
.
find
(
(
e
:
{
pattern
:
string
;
class
:
string
}
)
=>
globToRe
(
e
.
pattern
)
.
test
(
p
)
)
;
expect
(
{
p
,
cls
:
hit
?.
class
}
)
.
toEqual
(
{
p
,
cls
:
"artifact"
}
)
;
}
}
)
;
test
(
"the allowlist still ends with the user-additions marker"
,
(
)
=>
{
// Additions below it survive re-init; a glob added above would be silently
// overwritten the next time gstack-artifacts-init runs.
expect
(
heredoc
(
"\\$ALLOWLIST_TMP"
)
.
trimEnd
(
)
)
.
toMatch
(
/
#
-
-
-
-
U
S
E
R
A
D
D
I
T
I
O
N
S
B
E
L
O
W
-
-
-
-
/
)
;
}
)
;
}
)
;
You can’t perform that action at this time.