Skip to content

Commit 8a64e28

Browse files
committed
Move masking flag to src/base
1 parent e393f1c commit 8a64e28

File tree

17 files changed

+45
-30
lines changed

17 files changed

+45
-30
lines changed

src/HttpHeader.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,15 +669,15 @@ HttpHeader::parse(const char *header_start, size_t hdrLen, Http::ContentLengthIn
669669

670670
/* packs all the entries using supplied packer */
671671
void
672-
HttpHeader::packInto(Packable * p, Security::MaskSensitiveInfo masking) const
672+
HttpHeader::packInto(Packable * p, MaskSensitiveInfo masking) const
673673
{
674674
HttpHeaderPos pos = HttpHeaderInitPos;
675675
const HttpHeaderEntry *e;
676676
assert(p);
677-
debugs(55, 7, this << " into " << p << (masking == Security::MaskSensitiveInfo::on ? " while masking" : ""));
677+
debugs(55, 7, this << " into " << p << (masking == MaskSensitiveInfo::on ? " while masking" : ""));
678678
/* pack all entries one by one */
679679
while ((e = getEntry(&pos))) {
680-
if (masking == Security::MaskSensitiveInfo::off) {
680+
if (masking == MaskSensitiveInfo::off) {
681681
e->packInto(p);
682682
continue;
683683
}

src/HttpHeader.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "anyp/ProtocolVersion.h"
1313
#include "base/LookupTable.h"
14+
#include "base/MaskSensitiveInfo.h"
1415
#include "http/RegisteredHeaders.h"
1516
/* because we pass a spec by value */
1617
#include "HttpHeaderMask.h"
@@ -99,7 +100,7 @@ class HttpHeader
99100
int parse(const char *buf, size_t buf_len, bool atEnd, size_t &hdr_sz, Http::ContentLengthInterpreter &interpreter);
100101
/// Serialize HTTP Fields using HTTP/1.1 syntax in RFC 9112 section 5.
101102
/// Optionally redact credentials in HTTP Authentication headers.
102-
void packInto(Packable *, Security::MaskSensitiveInfo) const;
103+
void packInto(Packable *, MaskSensitiveInfo) const;
103104
HttpHeaderEntry *getEntry(HttpHeaderPos * pos) const;
104105
HttpHeaderEntry *findEntry(Http::HdrType id) const;
105106
/// deletes all fields with a given name, if any.

src/HttpReply.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void
8787
HttpReply::packHeadersUsingFastPacker(Packable &p) const
8888
{
8989
sline.packInto(&p);
90-
header.packInto(&p, Security::MaskSensitiveInfo::off);
90+
header.packInto(&p, MaskSensitiveInfo::off);
9191
p.append("\r\n", 2);
9292
}
9393

src/HttpRequest.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,13 +334,13 @@ HttpRequest::swapOut(StoreEntry * e)
334334
{
335335
assert(e);
336336
e->buffer();
337-
pack(e, Security::MaskSensitiveInfo::off);
337+
pack(e, MaskSensitiveInfo::off);
338338
e->flush();
339339
}
340340

341341
/* packs request-line and headers, appends <crlf> terminator */
342342
void
343-
HttpRequest::pack(Packable * p, Security::MaskSensitiveInfo mask) const
343+
HttpRequest::pack(Packable * p, MaskSensitiveInfo mask) const
344344
{
345345
assert(p);
346346
/* pack request-line */
@@ -358,7 +358,7 @@ void
358358
httpRequestPack(void *obj, Packable *p)
359359
{
360360
HttpRequest *request = static_cast<HttpRequest*>(obj);
361-
request->pack(p, Security::MaskSensitiveInfo::off);
361+
request->pack(p, MaskSensitiveInfo::off);
362362
}
363363

364364
/* returns the length of request line + headers + crlf */

src/HttpRequest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class HttpRequest: public Http::Message
206206

207207
/// Serialize HTTP Request using HTTP/1.1 origin-form syntax in RFC 9112 section 3.
208208
/// \copydoc HttpHeader::packInto()
209-
void pack(Packable *, Security::MaskSensitiveInfo) const;
209+
void pack(Packable *, MaskSensitiveInfo) const;
210210

211211
static void httpRequestPack(void *obj, Packable *p);
212212

src/base/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ libbase_la_SOURCES = \
4848
JobWait.h \
4949
Lock.h \
5050
LookupTable.h \
51+
MaskSensitiveInfo.h \
5152
OnOff.h \
5253
Packable.h \
5354
PackableStream.h \

src/base/MaskSensitiveInfo.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (C) 1996-2025 The Squid Software Foundation and contributors
3+
*
4+
* Squid software is distributed under GPLv2+ license and includes
5+
* contributions from numerous individuals and organizations.
6+
* Please see the COPYING and CONTRIBUTORS files for details.
7+
*/
8+
9+
#ifndef SQUID_SRC_BASE_MASKSENSITIVEINFO_H
10+
#define SQUID_SRC_BASE_MASKSENSITIVEINFO_H
11+
12+
#include "base/OnOff.h"
13+
14+
/// Flags for explicit decisions on handling of sensitive information.
15+
using MaskSensitiveInfo = OnOff;
16+
17+
#endif /* SQUID_SRC_BASE_MASKSENSITIVEINFO_H */

src/client_side.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,22 +327,22 @@ prepareLogWithRequestDetails(HttpRequest *request, const AccessLogEntryPointer &
327327
if (Config.onoff.log_mime_hdrs) {
328328
MemBuf mb;
329329
mb.init();
330-
request->header.packInto(&mb, Security::MaskSensitiveInfo::off);
330+
request->header.packInto(&mb, MaskSensitiveInfo::off);
331331
//This is the request after adaptation or redirection
332332
aLogEntry->headers.adapted_request = xstrdup(mb.buf);
333333

334334
// the virgin request is saved to aLogEntry->request
335335
if (aLogEntry->request) {
336336
mb.reset();
337-
aLogEntry->request->header.packInto(&mb, Security::MaskSensitiveInfo::off);
337+
aLogEntry->request->header.packInto(&mb, MaskSensitiveInfo::off);
338338
aLogEntry->headers.request = xstrdup(mb.buf);
339339
}
340340

341341
#if USE_ADAPTATION
342342
const Adaptation::History::Pointer ah = request->adaptLogHistory();
343343
if (ah != nullptr) {
344344
mb.reset();
345-
ah->lastMeta.packInto(&mb, Security::MaskSensitiveInfo::off);
345+
ah->lastMeta.packInto(&mb, MaskSensitiveInfo::off);
346346
aLogEntry->adapt.last_meta = xstrdup(mb.buf);
347347
}
348348
#endif
@@ -724,7 +724,7 @@ clientPackRangeHdr(const HttpReplyPointer &rep, const HttpHdrRangeSpec * spec, S
724724

725725
httpHeaderAddContRange(&hdr, *spec, rep->content_length);
726726

727-
hdr.packInto(mb, Security::MaskSensitiveInfo::off);
727+
hdr.packInto(mb, MaskSensitiveInfo::off);
728728
hdr.clean();
729729

730730
/* append <crlf> (we packed a header, not a reply) */

src/clients/HttpTunneler.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Http::Tunneler::writeRequest()
152152
&hdr_out,
153153
connection->getPeer(),
154154
flags);
155-
hdr_out.packInto(&mb, Security::MaskSensitiveInfo::off);
155+
hdr_out.packInto(&mb, MaskSensitiveInfo::off);
156156
hdr_out.clean();
157157
mb.append("\r\n", 2);
158158

src/errorpage.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ ErrorState::Dump(MemBuf * mb)
886886
body << "HTTP Request:\r\n";
887887
MemBuf r;
888888
r.init();
889-
request->pack(&r, Security::MaskSensitiveInfo::on);
889+
request->pack(&r, MaskSensitiveInfo::on);
890890
body << r.content();
891891
}
892892

@@ -1149,7 +1149,7 @@ ErrorState::compileLegacyCode(Build &build)
11491149
break;
11501150
}
11511151
else if (request)
1152-
request->pack(&mb, Security::MaskSensitiveInfo::on);
1152+
request->pack(&mb, MaskSensitiveInfo::on);
11531153
else
11541154
p = "[no request]";
11551155
break;

0 commit comments

Comments
 (0)