Continuing from our previous video, I will go ahead and create a tools directory here.
In there I will create this Python file by the name zap proxy.
So that in this particular tool we would invoke the CLI from zap proxy and collect the results.
So for that I'll import a couple of native libraries from Python OS is operating system and subprocesses
and also from crew I pools.
I will import the tools tool library.
Now let me invoke the tool decorator and say this is zap proxy general use.
I'll come back to this tools problem.
We can fix it later on.
And then I'll give the name of the function as zap proxy general use.
I'll go with the website which we want to scan.
And then the response of this will be the text which is in a string format.
I will go ahead and give Python documentation quickly.
Pen testing tool for web security scan using Zap proxy.
So now what I'm going to do here is I'm going to use the imports I used as in like operating system.
I'll change my directory from my current execution.
I'll move to the one where I have installed these proxy.
So I will go ahead and go to program files.
Program files Zed attack proxy.
That's where it has installed the app.
Proxy details.
And now I'll go ahead and invoke the the base command.
So here is the base command that we would use to execute the CLI.
The proxy is part of the the batch script that is part of the installation.
We will use the quick URL and the website that needs to be scanned.
As for pen testing say make it go quicker.
It's a quick progress and it's a command prompt.
This website URL here is basically the one that we would pass here.
So the Agentic experience is smart enough to know that it will extract this URL and inject it to this
tool.
We'll see how all of that works.
Now I'm going to go ahead and run this process.
So this is something that you would want to know as part of the Python or any other programming language
execution.
You have to invoke the CLI for CLI.
It's a different process altogether outside the Python runtime.
So for that subprocess is the package that enables the execution of the process outside the runtime.
So here I will say subprocess p open.
And then I'll give the base command as as one of the parameters I'll say shell is true.
It's a shell scripting and then stdout.
So it's basically the output is subprocess dot pipe.
And there's an error that says subprocess pipe.
And now I will go ahead and capture the output and error here.
Process is will invoke the communicate function which will communicate with the external I call that
it invoked.
Get the response back.
And if it's an error or if it's a response, whatever it is, we will capture it.
In case if it's an error, then we raise an exception.
And if it went well then we return the output in UTF eight format.
This is great.
Let's go ahead and now create the crew base class, where we want to invoke and bring everything that
we wrote together and execute it.
So I have to play around with my packaging structure and eventually the errors are gone because some
of the crew I Python packages were not installed properly.
Having said that, all issues have been resolved.
It was a packaging issue which is now fixed.
I'll go ahead and write the crew I agent and let's execute it together.
Bring every different element together and run it in our next video.
Thank you.
I'll see you in the next video.