Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
gh-aw/scripts/update-release-pins_test.sh at main · github/gh-aw · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
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 }}
github
gh-aw
Repository navigation
Code
Issues
337
(337)
Pull requests
13
(13)
Only collaborators can create PRs
Discussions
Actions
Projects
Wiki
Security and quality
15
(15)
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
gh-aw
/
scripts
/
update-release-pins_test.sh
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
executable file
·
145 lines (137 loc) · 5.67 KB
main
Breadcrumbs
gh-aw
/
scripts
/
update-release-pins_test.sh
Copy path
Top
File metadata and controls
Code
Blame
executable file
·
145 lines (137 loc) · 5.67 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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!
/usr/bin/env bash
set
+o histexpand
set
-euo pipefail
repo_root=
"
$(
cd
"
$(
dirname
"
${BASH_SOURCE[0]}
"
)
/..
"
&&
pwd
)
"
cd
"
$repo_root
"
work=
"
.release-pins-test-
$$
-
$RANDOM
"
(umask 077
;
mkdir
"
$work
"
)
trap
'
rm -rf "$work"
'
EXIT
mkdir -p
"
$work
/repo/scripts
"
"
$work
/repo/actions/setup/sh
"
"
$work
/bin
"
cp scripts/update-release-pins.sh
"
$work
/repo/scripts/
"
cp actions/setup/sh/release_integrity.sh
"
$work
/baseline
"
target=
"
$work
/repo/actions/setup/sh/release_integrity.sh
"
updater=
"
$work
/repo/scripts/update-release-pins.sh
"
printf
'
%064d fixture-asset.tar.gz\n
'
0
>
"
$work
/manifest
"
export
MOCK_MANIFEST=
"
$PWD
/
$work
/manifest
"
export
MOCK_CURL_LOG=
"
$PWD
/
$work
/curl.log
"
export
MOCK_EXPECTED_URL=
"
https://github.com/github/gh-aw-firewall/releases/download/v9.8.7/checksums.txt
"
cat
>
"
$work
/bin/curl
"
<<
'
MOCK
'
#!/usr/bin/env bash
set -euo pipefail
echo called >> "$MOCK_CURL_LOG"
[ "$#" -eq 12 ]
[ "$1" = --disable ]
[ "$2" = --proto ] && [ "$3" = '=https' ]
[ "$4" = --proto-redir ] && [ "$5" = '=https' ]
[ "$6" = --fail ] && [ "$7" = --silent ] && [ "$8" = --show-error ]
[ "$9" = --location ] && [ "${10}" = --output ]
[ "${12}" = "$MOCK_EXPECTED_URL" ]
[ "${MOCK_CURL_FAIL:-0}" = 0 ] || exit 22
cp "$MOCK_MANIFEST" "${11}"
MOCK
chmod +x
"
$work
/bin/curl
"
export
PATH=
"
$PWD
/
$work
/bin:
$PATH
"
hash_file
() {
if
command
-v sha256sum
>
/dev/null
2>&1
;
then
sha256sum
"
$1
"
|
awk
'
{print $1}
'
else
shasum -a 256
"
$1
"
|
awk
'
{print $1}
'
fi
}
digest=
"
$(
hash_file
"
$work
/manifest
"
)
"
wrong_digest=
"
$(
printf
'
%064d
'
1
)
"
passed=0
reject
() {
local
name=
"
$1
"
shift
cp
"
$target
"
"
$work
/before
"
if
bash
"
$updater
"
"
$@
"
>
"
$work
/output
"
2>&1
;
then
echo
"
FAIL:
$name
unexpectedly succeeded
"
>&2
exit
1
fi
cmp -s
"
$target
"
"
$work
/before
"
||
{
echo
"
FAIL:
$name
modified the pin helper
"
>&2
exit
1
}
passed=
$((
passed
+
1
))
}
cp
"
$work
/baseline
"
"
$target
"
reject
"
missing arguments
"
reject
"
unsupported repository
"
evil/repository v9.8.7 checksums.txt
"
$digest
"
reject
"
wrong manifest
"
github/gh-aw-firewall v9.8.7 SHA256SUMS.txt
"
$digest
"
reject
"
asset path traversal
"
github/gh-aw-firewall v9.8.7 ../checksums.txt
"
$digest
"
reject
"
version URL injection
"
github/gh-aw-firewall
'
v9.8.7?token=secret
'
checksums.txt
"
$digest
"
reject
"
prerelease tag
"
github/gh-aw-firewall v9.8.7-rc1 checksums.txt
"
$digest
"
reject
"
invalid expected digest
"
github/gh-aw-firewall v9.8.7 checksums.txt BAD
reject
"
uppercase expected digest
"
github/gh-aw-firewall v9.8.7 checksums.txt
"
$(
printf
'
%064d
'
0
|
tr 0 A
)
"
[
!
-e
"
$MOCK_CURL_LOG
"
]
||
{
echo
"
FAIL: unsupported input caused a download
"
>&2
;
exit
1
;
}
reject
"
manifest hash mismatch
"
github/gh-aw-firewall v9.8.7 checksums.txt
"
$wrong_digest
"
export
MOCK_CURL_FAIL=1
reject
"
download failure
"
github/gh-aw-firewall v9.8.7 checksums.txt
"
$digest
"
unset
MOCK_CURL_FAIL
cp
"
$work
/manifest
"
"
$work
/nonempty-manifest
"
:
>
"
$work
/manifest
"
reject
"
empty manifest
"
github/gh-aw-firewall v9.8.7 checksums.txt
"
$(
hash_file
"
$work
/manifest
"
)
"
cp
"
$work
/nonempty-manifest
"
"
$work
/manifest
"
for
defect
in
short uppercase extra-field bad-version bad-repository bad-asset duplicate blank
;
do
awk -v defect=
"
$defect
"
'
/^github\/gh-aw-firewall / && !changed++ {
if (defect == "short") $4 = "abc"
if (defect == "uppercase") $4 = toupper($4)
if (defect == "extra-field") $5 = "extra"
if (defect == "bad-version") $2 = "latest"
if (defect == "bad-repository") $1 = "other/repo"
if (defect == "bad-asset") $3 = "other.txt"
if (defect == "duplicate") print
if (defect == "blank") print ""
}
{ print }
'
"
$work
/baseline
"
>
"
$target
"
reject
"
$defect
table row
"
github/gh-aw-firewall v9.8.7 checksums.txt
"
$digest
"
done
awk
'
$0 != "PINS" { print }
'
"
$work
/baseline
"
>
"
$target
"
reject
"
unterminated table
"
github/gh-aw-firewall v9.8.7 checksums.txt
"
$digest
"
awk
'
!/<<.*PINS/ { print }
'
"
$work
/baseline
"
>
"
$target
"
reject
"
missing table start
"
github/gh-aw-firewall v9.8.7 checksums.txt
"
$digest
"
cp
"
$work
/baseline
"
"
$target
"
cat
"
$work
/baseline
"
>>
"
$target
"
reject
"
multiple pin tables
"
github/gh-aw-firewall v9.8.7 checksums.txt
"
$digest
"
cp
"
$work
/baseline
"
"
$target
"
bash
"
$updater
"
github/gh-aw-firewall 9.8.7 checksums.txt
"
$digest
"
awk -v digest=
"
$digest
"
'
$0 == "PINS" { print "github/gh-aw-firewall v9.8.7 checksums.txt " digest }
{ print }
'
"
$work
/baseline
"
>
"
$work
/expected
"
cmp
"
$target
"
"
$work
/expected
"
passed=
$((
passed
+
1
))
bash
"
$updater
"
github/gh-aw-firewall v9.8.7 checksums.txt
"
$digest
"
cmp
"
$target
"
"
$work
/expected
"
passed=
$((
passed
+
1
))
printf
'
another independently authenticated manifest\n
'
>
"
$work
/manifest
"
reject
"
replacement of different digest
"
github/gh-aw-firewall v9.8.7 checksums.txt
"
$(
hash_file
"
$work
/manifest
"
)
"
export
MOCK_EXPECTED_URL=
"
https://github.com/github/copilot-cli/releases/download/v9.8.7/SHA256SUMS.txt
"
digest=
"
$(
hash_file
"
$work
/manifest
"
)
"
bash
"
$updater
"
github/copilot-cli v9.8.7 SHA256SUMS.txt
"
$digest
"
awk -v digest=
"
$digest
"
'
$0 == "PINS" { print "github/copilot-cli v9.8.7 SHA256SUMS.txt " digest }
{ print }
'
"
$work
/expected
"
>
"
$work
/expected-both
"
cmp
"
$target
"
"
$work
/expected-both
"
passed=
$((
passed
+
1
))
#
A concurrent edit during the fetch must not be overwritten.
cat
>
"
$work
/bin/curl
"
<<
'
MOCK
'
#!/usr/bin/env bash
set -euo pipefail
printf '\n# concurrent edit\n' >> "$MOCK_TARGET"
cp "$MOCK_MANIFEST" "${11}"
MOCK
export
MOCK_TARGET=
"
$PWD
/
$target
"
cp
"
$target
"
"
$work
/before
"
if
bash
"
$updater
"
github/copilot-cli v9.8.7 SHA256SUMS.txt
"
$digest
"
>
"
$work
/output
"
2>&1
;
then
echo
"
FAIL: concurrent edit unexpectedly succeeded
"
>&2
exit
1
fi
printf
'
\n# concurrent edit\n
'
>>
"
$work
/before
"
cmp
"
$target
"
"
$work
/before
"
passed=
$((
passed
+
1
))
echo
"
PASS:
$passed
offline release pin authoring checks
"
You can’t perform that action at this time.