Skip to content

Develop#192

Open
lstruman wants to merge 412 commits into
mainfrom
develop
Open

Develop#192
lstruman wants to merge 412 commits into
mainfrom
develop

Conversation

@lstruman
Copy link
Copy Markdown
Contributor

No description provided.

lstruman added 30 commits July 19, 2024 15:34
Forward webconfig notifications without filtering
…ons-all

Forward webconfig notifications without filtering
generate notifications if states are corrected by versions from devices
generate notifications if states are corrected by versions from devices
Return 504 if xconf GET returns timeout/context_cancellation
Add debug loggings for 403 error analysis
Add debug loggings for 403 error analysis
Add debug loggings for 403 error analysis
return 404 for NONE-REBOOT without subdocs
return 404 for NONE-REBOOT without subdocs
Update the sample Cassandra configuration to use a non-SSL connection
Revert "Update the sample Cassandra configuration to use a non-SSL co…
Add cassandra config for tls as we upgraded the dependency libs in go…
Add tls configs to work with a targeted cassandra env
Fix a bug that wronge hocon paths wwere used to read kafka tls configs
Add back cassandra ciphersuite configs removed by mistake
…document columns product_class and customer_type
Store new headers X-System-Product-Class and X-System-Type into root_…
Comment thread db/service.go
firmwareVersion := rHeader.Get(common.HeaderFirmwareVersion)
firmwareVersion, err := rHeader.Get(common.HeaderFirmwareVersion)
if err != nil {
log.WithFields(tfields).Warn(err)

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

Sensitive data returned by HTTP request headers
flows to a logging call.

Copilot Autofix

AI 2 months ago

In general, the fix is to ensure that values derived from HTTP request headers are not logged in clear text when they may be sensitive or attacker-controlled. Instead of constructing error messages that embed the full header value, log only metadata (such as header name) or, if needed, a redacted/obfuscated form of the value. This keeps logs useful for debugging while avoiding clear-text exposure of potentially sensitive data.

The specific best fix here is to change ReqHeader.Get in common/req_header.go so that, when it detects a non-printable (invalid) value, it generates an error message that does not include %v for the raw header value. We can keep the header name and a generic description (e.g., “invalid value discarded”) and maybe the length of the value, but not the content itself. This change preserves existing behavior (invalid values are still rejected with an error) and only alters the text of that error. No callers need to change: BuildGetDocument will still log the error, but without leaking the header value.

Concretely:

  • In common/req_header.go, update the fmt.Errorf call in ReqHeader.Get to drop v from the formatted string (or replace it with a safe summary like its length).
  • No changes are required in db/service.go or http/multipart.go, as they will automatically benefit from the safer error message.
  • No new imports or methods are required; we only adjust the format string and arguments.
Suggested changeset 1
common/req_header.go
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/common/req_header.go b/common/req_header.go
--- a/common/req_header.go
+++ b/common/req_header.go
@@ -35,7 +35,8 @@
 func (h *ReqHeader) Get(k string) (string, error) {
 	v := h.Header.Get(k)
 	if !IsPrintable([]byte(v)) {
-		return "", fmt.Errorf("header %v invalid value %v discarded", k, v)
+		// Do not include the raw header value in the error to avoid logging potentially sensitive data.
+		return "", fmt.Errorf("header %v has an invalid value and was discarded", k)
 	}
 	return v, nil
 }
EOF
@@ -35,7 +35,8 @@
func (h *ReqHeader) Get(k string) (string, error) {
v := h.Header.Get(k)
if !IsPrintable([]byte(v)) {
return "", fmt.Errorf("header %v invalid value %v discarded", k, v)
// Do not include the raw header value in the error to avoid logging potentially sensitive data.
return "", fmt.Errorf("header %v has an invalid value and was discarded", k)
}
return v, nil
}
Copilot is powered by AI and may make mistakes. Always verify output.
Comment thread db/service.go Fixed
…en POST new payload and state changed from 4 to 2
fix a bug that error_code and error_details columns were not reset wh…
handle failed sqlite related tests during root_document schema change
add bitmap definitions for hotspotwantolan and ignitewifi
@rdkcmf-jenkins
Copy link
Copy Markdown
Contributor

b'## Blackduck scan failure details

Summary: 0 violations, 0 files pending approval, 1 file pending identification.

  • Protex Server Path: /home/blackduck/github/webconfig/192/rdkcentral/webconfig

  • Commit: df673c6

Report detail: gist'

@rdkcmf-jenkins
Copy link
Copy Markdown
Contributor

b'## WARNING: A Blackduck scan failure has been waived

A prior failure has been upvoted

  • Upvote reason: ok - consider code match as boilerplate

  • Commit: df673c6
    '

Comment thread db/service.go

productClass, err := rHeader.Get(common.HeaderProductClass)
if err != nil {
log.WithFields(tfields).Warn(err)

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

Sensitive data returned by HTTP request headers
flows to a logging call.

Copilot Autofix

AI about 1 month ago

General fix: never include raw sensitive/untrusted input in log messages or propagated errors that may be logged. For header validation, include only safe metadata (e.g., header key), not the header value.

Best targeted fix (no functional change): in common/req_header.go, update ReqHeader.Get so the returned error for non-printable input does not interpolate v. Keep return semantics unchanged (return "", error) so existing control flow and validation behavior remain intact. This single change prevents all downstream logs (including db/service.go:99) from containing clear-text header values.

Required edits:

  • File: common/req_header.go
  • Region: ReqHeader.Get method, line with fmt.Errorf("header %v invalid value %v discarded", k, v)
  • Change: replace with a sanitized message like fmt.Errorf("header %v has invalid value discarded", k)

No new methods/imports/dependencies needed.

Suggested changeset 1
common/req_header.go
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/common/req_header.go b/common/req_header.go
--- a/common/req_header.go
+++ b/common/req_header.go
@@ -35,7 +35,7 @@
 func (h *ReqHeader) Get(k string) (string, error) {
 	v := h.Header.Get(k)
 	if !IsPrintable([]byte(v)) {
-		return "", fmt.Errorf("header %v invalid value %v discarded", k, v)
+		return "", fmt.Errorf("header %v has invalid value discarded", k)
 	}
 	return v, nil
 }
EOF
@@ -35,7 +35,7 @@
func (h *ReqHeader) Get(k string) (string, error) {
v := h.Header.Get(k)
if !IsPrintable([]byte(v)) {
return "", fmt.Errorf("header %v invalid value %v discarded", k, v)
return "", fmt.Errorf("header %v has invalid value discarded", k)
}
return v, nil
}
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants