-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Traversing the BashLex AST Node. #29
Comments
I think you want to look for a CommandNode and see if its first WordNode is 'rm'. Then traverse the subsequent WordNodes (which are the arguments to rm) and do the rest of the checks. Does that answer your question? |
Sounds Good to me, can you also explain to check if the file is updating something in /temp? For Example: import bashlex I want to check if a particular Node is a redirect node or any other particular type of node., I can Manually write up an split function for that, but I am assuming that there is better a way to access this data. |
Late to the party, I just discovered this library the other day. So, first of all, great work, also on explainshell! I'd like to go back to the traversal question. I know that I can implement it myself because everything is basically just lists but is there maybe code already that makes it more convenient, like for @shivamgupta01's use case when I only want to hook into visited redirect nodes? |
I think the |
Hey, just wanted to shamelessly plug my package here. I wrote a ton of code that easily allows for bash AST manipulation in this way if anyone is interested in the future: |
Hey,
I am trying to traverse through the bashlex.ast.node to find something specific, such as if the bash command is writing something to temp or deleting any file.
Till now I was trying manual check
if (tree[0].tree[i].word) == 'rm' :
return command
But I assume its not the right way to traverse the Bashlex AST tree, what if I need to find the files with are writing to Temp directory.
Can you shed some light on how I can efficiently traverse through the AST and fulfill the above requirement.
The text was updated successfully, but these errors were encountered: