IP Library Granted Patent US 12,405,877
Granted Patent B1
US 12,405,877 · App. 17/841,329 · Granted Sep 2, 2025

String analysis in a code scanning engine

Inventor: Omer Tripp (San Jose, CA)
Assignee: Amazon Technologies, Inc.
G06F11/3616G06F11/3608
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,405,877
App. No.
17/841,329
Granted
Sep 2, 2025
Kind
B1
Abstract

A method for string analysis in a code scanning engine comprises a string analysis rule definition, the string analysis rule definition including a search pattern and a test criterion. At least a portion of a string in a source code file is determined to be a match to the search pattern. The test criterion is evaluated against at least a portion of the string. An indication of a result of the evaluation of the first test criterion is provided.

Claims (46)

1. A computer-implemented method for scanning a source code file, the method comprising:

obtaining, by a code scanning service implemented as code executed by one or more processers of a cloud provider network, a string analysis rule definition, the string analysis rule definition including a first search pattern, a second search pattern, and a first test criterion, wherein the first search pattern is a regular expression and wherein the first test criterion is a logical expression evaluated against at least a portion of a string matching the first search pattern;

compiling, by the code scanning service, objects within the source code file;

obtaining, by the code scanning service, a request to perform a code scan on the source code file using the string analysis rule definition;

generating a string structure of a first string in the source code file, the string structure including a plurality of string pieces, each string piece having zero or more properties, wherein the first string is a sequence of characters, and wherein each string piece is a sequence of characters;

determining that a first portion of the first string is a first match to the first search pattern, wherein the first string is associated with a first string piece of the plurality of string pieces;

determining that a second portion of the first string is a second match to the second search pattern;

evaluating the first test criterion against a property of the first string piece, wherein the first test criterion evaluates a relative position of the first match to the second match within the first string; and

providing an indication of a result of the evaluation of the first test criterion.

2. The computer-implemented method of claim 1 , wherein the property of the first string piece is whether the first string piece is based at least in part on an untrusted input.

3. The computer-implemented method of claim 1 , wherein each string piece of the plurality of string pieces is another string found in the source code file.

4. A computer-implemented method for scanning a source code file, the method comprising:

obtaining, by a code scanning service implemented as code executed by one or more processers of a cloud provider network, a string analysis rule definition, the string analysis rule definition including a first search pattern, a second search pattern, and a first test criterion;

compiling, by the code scanning service, objects within the source code file;

generating a string structure of a string in the source code file, the string structure including a plurality of string pieces, each string piece having zero or more properties, wherein the string is a sequence of characters, and wherein each string piece is a sequence of characters;

determining that a first portion of the string is a first match to the first search pattern;

determining that a second portion of the string is a second match to the second search pattern;

evaluating the first test criterion against at least a portion of the string, wherein the first test criterion evaluates a relative position of the first match to the second match within the string; and

providing an indication of a result of the evaluation of the first test criterion.

5. The computer-implemented method of claim 4 , wherein the portion of the string is associated with a first string piece of the plurality of string pieces.

6. The computer-implemented method of claim 5 , wherein evaluating the first test criterion against at least a portion of the string comprises evaluating the first test criterion against a property of the string inherited from the first string piece.

7. The computer-implemented method of claim 6 , wherein the property of the first string piece is whether the first string piece is based at least in part on an untrusted input.

8. The computer-implemented method of claim 4 , further comprising generating a string structure for each other string in the source code file, each string structure referencing zero or more string pieces.

9. The computer-implemented method of claim 4 , wherein the string analysis rule definition further includes a second search pattern and further comprising:

determining that at least a second portion of the string is a second match to the second search pattern; and

wherein the first test criterion evaluates a relative position of the first match to the second match within the string.

10. The computer-implemented method of claim 4 , wherein the first search pattern is a regular expression and wherein the first test criterion is a logical expression to be evaluated against at least a portion of a string including a match to the first search pattern.

11. The computer-implemented method of claim 4 , further comprising obtaining a request to perform a code scan on the source code file using the string analysis rule definition prior to determining that the string in the source code file includes the first match to the first search pattern.

12. The computer-implemented method of claim 4 , wherein the determining that the string in the source code file includes the first match to the first search pattern is performed by a virtual machine of a cloud provider network.

13. The computer-implemented method of claim 4 , wherein the indication is provided as part of a code review workflow, a code build workflow, a code deployment pipeline workflow, or an offline scanning workflow.

14. The computer-implemented method of claim 4 , wherein the string analysis rule definition is authored in a query language.

15. A system for scanning a source code file, the system comprising:

a first one or more electronic devices to implement a data store; and

a second one or more electronic devices to implement a code scanning service, the code scanning service including instructions that upon execution by one or more processers cause the code scanning service to:

obtain a string analysis rule definition from the data store, the string analysis rule definition including a first search pattern, a second search pattern, and a first test criterion;

compile objects within the source code file;

generate a string structure of a string in the source code file, the string structure including a plurality of string pieces, each string piece having zero or more properties, wherein the string is a sequence of characters, and wherein each string piece is a sequence of characters;

determine that a first portion of the string is a first match to the first search pattern;

determine that a second portion of the string is a second match to the second search pattern;

evaluate the first test criterion against at least a portion of the string, wherein the first test criterion evaluates a relative position of the first match to the second match within the string; and

provide an indication of a result of the evaluation of the first test criterion.

16. The system of claim 15 , wherein the portion of the string is associated with a first string piece of the plurality of string pieces.

17. The system of claim 16 , wherein to evaluate the first test criterion against at least a portion of the string comprises an evaluation of the first test criterion against a property of the string inherited from the first string piece.

18. The system of claim 17 , wherein the property of the first string piece is whether the first string piece is based at least in part on an untrusted input.

19. The system of claim 15 , wherein the code scanning service includes further instructions that upon execution cause the code scanning service to generate a string structure for each other string in the source code file, each string structure referencing zero or more string pieces.

20. The system of claim 15 , wherein the string analysis rule definition further includes a second search pattern, and wherein the code scanning service includes further instructions that upon execution cause the code scanning service to determine that at least a second portion of the string is a second match to the second search pattern, wherein the first test criterion evaluates a relative position of the first match to the second match within the string.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jun 15, 2022
From: TRIPP, OMER
To: AMAZON TECHNOLOGIES, INC.
Reel/Frame 060215/0170 →
References Cited (30)
US 11093641B1 · Whalen · 2021 [cited by examiner]
US 11113175B1 · Adamo · 2021 [cited by examiner]
US 11468074B1 · Holub · 2022 [cited by examiner]
US 11663110B2 · Dolby · 2023 [cited by examiner]
US 20080228466A1 · Sudhakar · 2008 [cited by examiner]
US 20120130983A1 · Ryan · 2012 [cited by examiner]
US 20120317143A1 · Pistoia · 2012 [cited by examiner]
US 20160132415A1 · Dillard · 2016 [cited by examiner]
US 20180025081A1 · Denninghoff · 2018 [cited by examiner]
US 20190146987A1 · Bhave · 2019 [cited by examiner]
US 20190205543A1 · Wei · 2019 [cited by examiner]
US 20200401502A1 · Zang · 2020 [cited by examiner]
US 20220414492A1 · Jezewski · 2022 [cited by examiner]
US 20230161689A1 · Walters · 2023 [cited by examiner]
US 20230177164A1 · Tamboli · 2023 [cited by examiner]
US 20230305942A1 · Thome · 2023 [cited by examiner]
CN 110110163A · 2019 [cited by examiner]
CN 110383238A · 2019 [cited by examiner]
CN 110704298A · 2020 [cited by examiner]
CN 111240982A · 2020 [cited by examiner]
WO WO2016053282A1 · 2016 [cited by examiner]
Fangqing Liu, Search-Based Algorithm With Scatter Search Strategy for Automated Test Case Generation of NLP Toolkit, 2019, pp. 1-13. https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=8726151 (Year: 2019). [cited by examiner]
English translation, Munoz et al. (WO 2016053282 A1), 2016, pp. 1-12. (Year: 2016). [cited by examiner]
Devika Sondhi, SEGATE: Unveiling Semantic Inconsistencies between Code and Specification of String Inputs, 2019, pp. 1-13. https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=8952371 (Year: 2019). [cited by examiner]
English translation, Hahn et al. (CN 110110163 A), 2019, pp. 1-20. (Year: 2019). [cited by examiner]
Ranjita Bhagwan, Learning Patterns in Configuration, 2021, pp. 1-12. https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=9678525 (Year: 2021). [cited by examiner]
Huang et al. (CN 111240982 A), 2020, pp. 1-10. (Year: 2020). [cited by examiner]
Leen Lambers, Model-Based Testing of Read Only Graph Queries, 2020, pp. 1-11. https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=9155876 (Year: 2020). [cited by examiner]
Jia et al. (CN 110704298 A), 2020, pp. 1-16. (Year: 2020). [cited by examiner]
Steven et al. (CN 110383238 A), 2019, pp. 1-42. (Year: 2019). [cited by examiner]
Cited By (1)
US 12,627,645