Artifactspublic-v0

curl

master
ply4 git calls152 ms289 KiB2 cachedprotocol v2
187 lines5.7 KiBRaw
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9 *
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.se/docs/copyright.html.
13 *
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24#include "unitcheck.h"
26#if defined(USE_GNUTLS) || defined(USE_WOLFSSL) || defined(USE_SCHANNEL) || \
27 defined(USE_MBEDTLS) || defined(USE_RUSTLS)
28#include "vtls/x509asn1.h"
30struct test1657_spec {
31 CURLcode (*setbuf)(const struct test1657_spec *spec, struct dynbuf *buf);
32 size_t n;
33 CURLcode result_exp;
34};
36static CURLcode make1657_nested(const struct test1657_spec *spec,
37 struct dynbuf *buf)
39 CURLcode result;
40 size_t i;
41 uint8_t open_undef[] = { 0x32, 0x80 };
42 uint8_t close_undef[] = { 0x00, 0x00 };
44 for(i = 0; i < spec->n; ++i) {
45 result = curlx_dyn_addn(buf, open_undef, sizeof(open_undef));
46 if(result)
47 return result;
48 }
49 for(i = 0; i < spec->n; ++i) {
50 result = curlx_dyn_addn(buf, close_undef, sizeof(close_undef));
51 if(result)
52 return result;
53 }
54 return CURLE_OK;
57static const struct test1657_spec test1657_specs[] = {
58 { make1657_nested, 3, CURLE_OK },
59 { make1657_nested, 16, CURLE_OK },
60 { make1657_nested, 17, CURLE_BAD_FUNCTION_ARGUMENT },
61 { make1657_nested, 1024, CURLE_BAD_FUNCTION_ARGUMENT },
62};
64static bool do_test1657(const struct test1657_spec *spec, size_t i,
65 struct dynbuf *buf)
67 CURLcode result;
68 struct Curl_asn1Element elem;
69 const uint8_t *in;
70 const uint8_t *ptr;
72 memset(&elem, 0, sizeof(elem));
73 curlx_dyn_reset(buf);
74 result = spec->setbuf(spec, buf);
75 if(result) {
76 curl_mfprintf(stderr, "test %zu: error setting buf %d\n", i, (int)result);
77 return FALSE;
78 }
79 in = curlx_dyn_uptr(buf);
80 ptr = getASN1Element(&elem, in, in + curlx_dyn_len(buf));
81 result = !ptr ? CURLE_BAD_FUNCTION_ARGUMENT :
82 ptr != in + curlx_dyn_len(buf) ? CURLE_SSL_CERTPROBLEM : CURLE_OK;
83 if(result != spec->result_exp) {
84 curl_mfprintf(stderr, "test %zu: expect result %d, got %d\n",
85 i, (int)spec->result_exp, (int)result);
86 return FALSE;
87 }
88 return TRUE;
91struct test1657_cert_spec {
92 const char * const pem;
93 bool exp_success;
94};
96static const struct test1657_cert_spec test1657_certs[] = {
97 { /* a valid certificate */
98 "MIIBGTCBzKADAgECAhQ8Ssn8BaVsqlKKccv81NFuKY1vATAFBgMrZXAwADAeFw0y"
99 "NjA5MDIwNDU0MjZaFw0yNjEwMDIwNDU0MjZaMAAwKjAFBgMrZXADIQBeG0S343s9"
100 "5yRmIK8xZmGvUmiiYvRH5ZMcPq6rvHHKwqNYMFYwNQYDKgMEBC4wADAqMAUGAytl"
101 "cAMhAPP5TXSe2WHt/bebbP8eHPXrG3LNxYz8TnHNgpwTFsT7MB0GA1UdDgQWBBR6"
102 "aqL9LrZiIpgYCy0X4fNrhgFQsTAFBgMrZXADQQALU0OHGcIvfTwyin/+u9csJ9hZ"
103 "W0c+XdHJY5uDdCR1O92K4Vnozf/QCe7ITOJ8aUnCs7Jgf5xrDgyXZNdum04A",
104 TRUE
105 },
106 { /* a certificate with "validity" element that has too long length */
107 "MIIBGTCBzKADAgECAhQ8Ssn8BaVsqlKKccv81NFuKY1vATAFBgMrZXAwADBZFw0y"
108 "NjA5MDIwNDU0MjZaFw0yNjEwMDIwNDU0MjZaMAAwKjAFBgMrZXADIQBeG0S343s9"
109 "5yRmIK8xZmGvUmiiYvRH5ZMcPq6rvHHKwqNYMFYwNQYDKgMEBC4wADAqMAUGAytl"
110 "cAMhAPP5TXSe2WHt/bebbP8eHPXrG3LNxYz8TnHNgpwTFsT7MB0GA1UdDgQWBBR6"
111 "aqL9LrZiIpgYCy0X4fNrhgFQsTAFBgMrZXADQQALU0OHGcIvfTwyin/+u9csJ9hZ"
112 "W0c+XdHJY5uDdCR1O92K4Vnozf/QCe7ITOJ8aUnCs7Jgf5xrDgyXZNdum04A",
113 FALSE
114 }
115};
117static bool test1657_parse_cert(size_t i,
118 const struct test1657_cert_spec *spec)
120 struct Curl_X509certificate cert;
121 CURLcode result;
122 uint8_t *cert_der;
123 size_t cert_der_len;
124 bool success;
126 result = curlx_base64_decode(spec->pem, &cert_der, &cert_der_len);
127 if(result) {
128 curl_mfprintf(stderr, "cert %zu: base64 decoding failed: %d\n",
129 i, (int)result);
130 return FALSE;
131 }
133 success = !Curl_parseX509(&cert, cert_der, cert_der + cert_der_len);
134 if(success != spec->exp_success) {
135 curl_mfprintf(stderr, "cert %zu: parsing DER %sfailed\n", i,
136 spec->exp_success ? "" : "should have ");
137 return FALSE;
138 }
140 curlx_free(cert_der);
141 return TRUE;
144static CURLcode test_unit1657(const char *arg)
146 UNITTEST_BEGIN_SIMPLE
148 size_t i;
149 bool all_ok = TRUE;
150 struct dynbuf dbuf;
152 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
153 curl_mfprintf(stderr, "curl_global_init() failed\n");
154 return TEST_ERR_MAJOR_BAD;
155 }
157 curlx_dyn_init(&dbuf, 32 * 1024);
159 for(i = 0; i < CURL_ARRAYSIZE(test1657_specs); ++i) {
160 if(!do_test1657(&test1657_specs[i], i, &dbuf))
161 all_ok = FALSE;
162 }
163 fail_unless(all_ok, "some getASN1Element() tests failed");
165 all_ok = TRUE;
166 for(i = 0; i < CURL_ARRAYSIZE(test1657_certs); ++i) {
167 if(!test1657_parse_cert(i, &test1657_certs[i]))
168 all_ok = FALSE;
169 }
170 fail_unless(all_ok, "some certificate tests failed");
172 curlx_dyn_free(&dbuf);
173 curl_global_cleanup();
175 UNITTEST_END_SIMPLE
178#else
180static CURLcode test_unit1657(const char *arg)
182 UNITTEST_BEGIN_SIMPLE
183 puts("not tested since getASN1Element() is not built in");
184 UNITTEST_END_SIMPLE
187#endif
Diagnostics4 git calls · 152 ms
CallStatusSizeTime0152 ms
discover200152 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200149 B · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=2
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=149
git.pkt.payload.max=78
git.ls_refs.count=2
git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit25 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=25
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=10
git.pkt.data=8
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=293470
git.pkt.payload.max=65516
git.sideband.band1.bytes=293354
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=87
git.pack.bytes=293354
git.pack.ofs_delta=0
git.pack.ref_delta=1
git.pack.chain.max=1
git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0
git.pack.full=86
Open pack map
fetch2002.2 KiB125 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=125
git.response.bytes=2206
git.response.cache=MISS
git.response.duration_ms=125
git.fetch.wants=f506fdb3419261349d7d6c2a463cc093bc486cac
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=2206
git.pkt.payload.max=2185
git.sideband.band1.bytes=2184
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
Ref
refs/heads/master
Commit
31c911efe5652725e930f4d2e60c9060e5f6646d
cf-ray
a5e2e905beb7ecfa
Request
0ec5ef33…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format