Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Copybook is a python module for parsing VSAM copybooks.
In addition, it provides indexes of column locations to help with parsing fixed width files based on positions within each line
pip install copybook
Copybook provides two methods for parsing copybooks: parse_file
and parse_string
. The result is a FieldGroup
object that represents the root of the copybook tree.
Examples:
import copybook
text = """
01 WORK-BOOK.
10 TAX-RATE PIC S9(13)V9(2)
SIGN LEADING SEPARATE.
"""
root = copybook.parse_string(text)
The FieldGroup
object provides a flatten
method that return a flat list of Field
objects.
Example:
import copybook
text = """
01 WORK-BOOK.
10 TAX-RATE PIC S9(13)V9(2)
SIGN LEADING SEPARATE.
10 AMOUNT PIC S9(4)V9(2).
"""
# copybook also provides a parse_file method that receives a text filename
root = copybook.parse_string(text)
# flatten returns a list of Fields and FieldGroups instead of traversing the tree
list_of_fields = root.flatten()
# dummy sample input
line = " -13452987654"
# loop over the fields and parse the relevant position in the line
for field in list_of_fields:
# FieldGroups are Copybook groups and contain Field objects as children
if type(field)==copybook.Field:
# each Field has a start_pos and a get_total_length method
# to identify the position within the raw line input
str_field = line[field.start_pos:field.start_pos+field.get_total_length()]
# Field provides a parse method that returns a str, int, or float based on the PIC
print(f"{field.name}: {field.parse(str_field)}")
PRs are always welcome!
If you encounter an unsupported copybook feature, please paste the copybook example along with whatever logs or error message you have received and open an issue.
Copybook uses the awesome PyParsing library for tokenization
MIT
FAQs
python copybook parser
We found that copybook demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.