Skip to content

Commit 3922a17

Browse files
committed
test(cpp): address bal codec review feedback
1 parent 1e7629d commit 3922a17

3 files changed

Lines changed: 377 additions & 351 deletions

File tree

‎cpp/ql/test/library-tests/dataflow/external-models/bal.cpp‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ namespace balxml {
125125

126126
char *source();
127127
void sink(char);
128+
void sink(bsl::string s);
128129

129130
// Stand-in for a bdlat sequence type.
130131
struct Record {
@@ -134,8 +135,8 @@ struct Record {
134135
// A tainted stream is made by reinterpreting a tainted bsl::string, as in bslx.cpp. baljsn
135136
// and balxml only accept bdlat sequence/choice types; the stubs do not enforce that, and
136137
// most tests decode into a bsl::string so the result can be read back. The *_struct_* tests
137-
// show that a decoded struct is tainted as a whole but not through its fields, because
138-
// field accesses are not taint steps (see TaintTrackingUtil.qll).
138+
// show whole-object taint without general object-to-field flow. TaintInheritingContent
139+
// (FlowSteps.qll) enables inheritance for selected fields; Record::name is not modeled this way.
139140

140141
// ===== balber (BER) =====
141142

@@ -252,7 +253,7 @@ void test_baljsn_struct_field_no_flow() {
252253
Record rec;
253254
BloombergLP::baljsn::Decoder decoder;
254255
decoder.decode(sb, &rec);
255-
sink(rec.name[0]); // no flow: field reads from a tainted object are not taint steps
256+
sink(rec.name[0]); // no flow: Record::name does not inherit whole-object taint
256257
}
257258

258259
// ===== balxml (XML) =====
@@ -273,6 +274,7 @@ void test_balxml_decode_istream_return() {
273274
BloombergLP::balxml::Decoder decoder;
274275
bsl::istream &r = decoder.decode(*is, &out, "uri");
275276
sink(*(char *)&r); // $ ir
277+
sink(out); // $ ir
276278
}
277279

278280
void test_balxml_decode_streambuf() {
@@ -328,6 +330,7 @@ void test_balxml_decodeAny_istream_return() {
328330
BloombergLP::balxml::Decoder decoder;
329331
bsl::istream &r = decoder.decodeAny(*is, &out);
330332
sink(*(char *)&r); // $ ir
333+
sink(out); // $ ir
331334
}
332335

333336
void test_balxml_decodeAny_streambuf() {
@@ -355,6 +358,7 @@ void test_balxml_decodeAny_AnyRef_istream_return() {
355358
BloombergLP::balxml::Decoder decoder;
356359
bsl::istream &r = decoder.decodeAny(*is, &any);
357360
sink(*(char *)&r); // $ ir
361+
sink(*(char *)&any); // $ ir
358362
}
359363

360364
void test_balxml_decodeAny_AnyRef_streambuf() {
@@ -388,6 +392,7 @@ void test_balxml_encode_ostream_return_from_object() {
388392
BloombergLP::balxml::Encoder encoder;
389393
bsl::ostream &r = encoder.encode(*(bsl::ostream *)buf, obj);
390394
sink(*(char *)&r); // $ ir
395+
sink(buf[0]); // $ ir
391396
}
392397

393398
void test_balxml_encode_ostream_return_from_stream() {
@@ -439,6 +444,7 @@ void test_balxml_encodeAny_ostream_return_from_object() {
439444
BloombergLP::balxml::Encoder encoder;
440445
bsl::ostream &r = encoder.encodeAny(*(bsl::ostream *)buf, obj);
441446
sink(*(char *)&r); // $ ir
447+
sink(buf[0]); // $ ir
442448
}
443449

444450
void test_balxml_encodeAnyToStream() {

0 commit comments

Comments
 (0)