Jira (FACT-3198) Fact keys and values should not contain embedded null bytes

32 views
Skip to first unread message

Josh Cooper (Jira)

unread,
Apr 18, 2023, 3:19:02 PM4/18/23
to puppe...@googlegroups.com
Josh Cooper created an issue
 
Facter / Bug FACT-3198
Fact keys and values should not contain embedded null bytes
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2023/04/18 12:18 PM
Priority: Normal Normal
Reporter: Josh Cooper

Facter 4 should scrub embedded null unicode code points from fact keys and values, because they cannot be stored in puppetdb, resuling in errors like the following when facts are stored in puppetdb:

org.postgresql.util.PSQLException: ERROR: invalid byte sequence for encoding "UTF8": 0x00

To reproduce:

 
PS C:\Users\Administrator> cat .\external\msi_info.yaml
---
msi_info:
  "Alteryx 2020.2 x64 Server (Remove only)\0e\0\0\0\x11":
    version: 2020.2.3.27789
    vendor: Alteryx
    installdate: ''
PS C:\Users\Administrator> facter --external-dir external msi_info
{
  Alteryx 2020.2 x64 Server (Remove only)\u0000e\u0000\u0000\u0000\u0011 => {
    installdate => "",
    vendor => "Alteryx",
    version => "2020.2.3.27789"
  }
}
PS C:\Users\Administrator> facter --version
4.3.1

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.20.11#820011-sha1:0629dd8)
Atlassian logo

Josh Cooper (Jira)

unread,
Apr 18, 2023, 3:25:01 PM4/18/23
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Apr 18, 2023, 3:26:02 PM4/18/23
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Component/s: Facter 4
Component/s: Facter 3

Tony Vu (Jira)

unread,
Apr 18, 2023, 4:18:02 PM4/18/23
to puppe...@googlegroups.com
Tony Vu updated an issue
Change By: Tony Vu
Facter 4 should scrub embedded null unicode code points from fact keys and values, because they cannot be stored in puppetdb, resuling resulting in errors like the following when facts are stored in puppetdb:


{{org.postgresql.util.PSQLException: ERROR: invalid byte sequence for encoding "UTF8": 0x00}}

To reproduce:

{noformat}


PS C:\Users\Administrator> cat .\external\msi_info.yaml
---
msi_info:
  "Alteryx 2020.2 x64 Server (Remove only)\0e\0\0\0\x11":
    version: 2020.2.3.27789
    vendor: Alteryx
    installdate: ''
PS C:\Users\Administrator> facter --external-dir external msi_info
{
  Alteryx 2020.2 x64 Server (Remove only)\u0000e\u0000\u0000\u0000\u0011 => {
    installdate => "",
    vendor => "Alteryx",
    version => "2020.2.3.27789"
  }
}
PS C:\Users\Administrator> facter --version
4.3.1
{noformat}

Acceptance criteria:
* spec tests with null unicode code points; make sure it covers all fact types
* Should this be restricted to the puppetdb terminus?
* shouldn't require any acceptance tests

Josh Cooper (Jira)

unread,
Apr 24, 2023, 7:37:03 PM4/24/23
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Apr 25, 2023, 11:35:01 AM4/25/23
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Apr 26, 2023, 4:13:03 PM4/26/23
to puppe...@googlegroups.com

Aria Li (Jira)

unread,
May 31, 2023, 5:29:03 PM5/31/23
to puppe...@googlegroups.com
Aria Li updated an issue
Change By: Aria Li
Facter 4 should scrub embedded null unicode code points from fact keys and values, because they cannot be stored in puppetdb, resulting in errors like the following when facts are stored in puppetdb:


{{org.postgresql.util.PSQLException: ERROR: invalid byte sequence for encoding "UTF8": 0x00}}

To reproduce:

{noformat}

PS C:\Users\Administrator> cat .\external\msi_info.yaml
---
msi_info:
  "Alteryx 2020.2 x64 Server (Remove only)\0e\0\0\0\x11":
    version: 2020.2.3.27789
    vendor: Alteryx
    installdate: ''
PS C:\Users\Administrator> facter --external-dir external msi_info
{
  Alteryx 2020.2 x64 Server (Remove only)\u0000e\u0000\u0000\u0000\u0011 => {
    installdate => "",
    vendor => "Alteryx",
    version => "2020.2.3.27789"
  }
}
PS C:\Users\Administrator> facter --version
4.3.1
{noformat}

Acceptance criteria:
* spec tests with null unicode code points; make sure it covers all fact types
*
Should this be restricted to the puppetdb terminus?
*
shouldn't require any acceptance tests

* If a custom, extdrnal data or executable fact emits a valid UTF-8 string containing an embedded null byte,then facter should reject the string in the same way it does if the string is not valid UTF-8
This message was sent by Atlassian Jira (v8.20.21#820021-sha1:38274c8)
Atlassian logo

Aria Li (Jira)

unread,
May 31, 2023, 6:45:02 PM5/31/23
to puppe...@googlegroups.com
* shouldn't require any acceptance tests
* If a custom, extdrnal data or executable fact emits a valid UTF-8 string containing an embedded null byte,then facter should reject the string in the same way it does if the string is not valid UTF-8

** Within [normalize_string in normalization.rb|[https://github.com/puppetlabs/facter/blob/04d3d0e34bfa2503eb83442279d8e04e15a788f1/lib/facter/custom_facts/util/normalization.rb#L50-L60],] somewhere between line 55-57, the function should scan the string value to look for null character(s) and raise a normalization error just like how we do when the string can't be encoded into UTF-8

Aria Li (Jira)

unread,
May 31, 2023, 6:45:03 PM5/31/23
to puppe...@googlegroups.com
* If a custom, extdrnal data or executable fact emits a valid UTF-8 string containing an embedded null byte,then facter should reject the string in the same way it does if the string is not valid UTF-8 (see FACT-1902)

** Within [normalize_string in normalization.rb| [https://github.com/puppetlabs/facter/blob/04d3d0e34bfa2503eb83442279d8e04e15a788f1/lib/facter/custom_facts/util/normalization.rb #L50-L60],] somewhere between line 55-57, the function should scan the string value to look for null character(s) and raise a normalization error just like how we do when the string can't be encoded into UTF-8

Josh Cooper (Jira)

unread,
Jun 1, 2023, 12:34:02 PM6/1/23
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sprint: Phoenix 2023-06-21

Josh Cooper (Jira)

unread,
Jun 1, 2023, 12:39:01 PM6/1/23
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jun 1, 2023, 1:56:02 PM6/1/23
to puppe...@googlegroups.com

Tony Vu (Jira)

unread,
Jun 7, 2023, 5:48:02 PM6/7/23
to puppe...@googlegroups.com

Christopher Thorn (Jira)

unread,
Jun 8, 2023, 6:49:01 PM6/8/23
to puppe...@googlegroups.com
Christopher Thorn updated an issue
Change By: Christopher Thorn
Fix Version/s: FACT 4.4.1
Fix Version/s: FACT 4.4.2
Reply all
Reply to author
Forward
0 new messages