Skip to main content

EnhancedPHPJoern Framework Cpg2Code Library

Introduction

This framework helps you convert code from CodePropertyGraph of PHP.

Installation

install from pip (not public yet)

pip3 install cpg2code

install from source code

git clone 
python setup.py install

Usage

from enhanced_phpjoern_framework import Neo4jEngine
from enhanced_phpjoern_framework.graph_traversal import ControlGraphForwardTraversal
from cpg2code.cpg2code_factory import Cpg2CodeFactory
# WordPress-5.7.1/wp-load.php
neo4j_engine = Neo4jEngine.from_dict(NEO4J_DEFAULT_CONFIG)
traversal_entity = ControlGraphForwardTraversal(neo4j_engine)
file = neo4j_engine.get_file_name_belong_node('wp-load.php')
x = neo4j_engine.get_ast_child_node(neo4j_engine.get_ast_child_node(file))
origin = neo4j_engine.get_ast_root_node(x)
traversal_entity.origin = [origin]
traversal_entity.run()
rec = traversal_entity.get_record()  # type:nx.DiGraph
rec_list = [k for k, p in rec.nodes.items()]
result = Cpg2CodeFactory.extract_code(neo4j_engine, rec_list)
print(result)

The compare of result can be seen as follows(the left is the source file and the right is the generated file)

http://github.com/ninthDevilHAUNSTER/cpg2code/raw/master/example/result_cmp.png

Changelog

See [CHANGES.md](https://github.com/ninthDevilHAUNSTER/code2cpg/blob/master/CHANGES.md)

Authors

See [AUTHORS.md](https://github.com/ninthDevilHAUNSTER/code2cpg/blob/master/AUTHORS.md)

License

See [LICENSE.txt](https://github.com/ninthDevilHAUNSTER/code2cpg/blob/master/LICENSE.txt)

Metadata

Release files for cpg2code 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cpg2code 1.0.3
File Size Uploaded Provenance Actions
cpg2code-1.0.3.tar.gz 16.0 kB Without provenance Details for cpg2code-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cpg2code 1.0.3
File Interpreter ABI Platform Actions
cpg2code-1.0.3-py2.py3-none-any.whl Python 3, Python 2 none any Details for cpg2code-1.0.3-py2.py3-none-any.whl

Total release size: 31.6 kB

Release files / cpg2code-1.0.3.tar.gz

Download URL cpg2code-1.0.3.tar.gz
Size 16.0 kB
Tags Source
SHA-256 checksum
How to use checksums
93f1d4606bab3293c98b9c1dc29db72fca373d27df3e27ffdee4446a0bdd92e3
BLAKE2b-256 checksum
How to use checksums
1ad70c237e68d6883285450fe1e9ed8934c3b6baf0d877d84639bfc2a4a76426
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Release files / cpg2code-1.0.3-py2.py3-none-any.whl

Download URL cpg2code-1.0.3-py2.py3-none-any.whl
Size 15.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
57dc18ab32343f2237736d2bc6bf6b7155f0229f679e335adeaff1aad15b611d
BLAKE2b-256 checksum
How to use checksums
cf436c5674ff9cac2102c982b8e3c43d8d373b743eb65c27737191f38aaa0c0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Security for cpg2code 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page