OWASP / pysap

pysap is an open source Python library that provides modules for crafting and sending packets using SAP's NI, Diag, Enqueue, Router, MS, SNC, IGS, RFC and HDB protocols.
https://owasp.org/www-project-core-business-application-security/
GNU General Public License v2.0
220 stars 61 forks source link

Replacing SAP RPA Automation with PySAP? #44

Closed Marc-Girard closed 2 years ago

Marc-Girard commented 2 years ago

Hi good people of the PySAP Community,

I've been monitoring your fine project for a while; it is so cool and interesting!

I'm currently working as a software dev, doing SAP workflow automation. Our SAP gouvernance is very rigid, we don't even have the scripting enabled for clients so, I rely mostly on RPAs to do the work. It is kind of slow and "uncertain" as a simple change to the UI can break the whole process.

Now, I'd like to know if I could use your library to mimic the SAP GUI calls to our SAP servers. I don't do nothing fancy really, mostly reports and check in the P50 module for finances. Had a quick look at the examples, haven't found nothing that's really "full duplex", it might be me or it might be simply out of scope.

Please let me know if this is doable with PySAP and maybe a simple example on how to send and receive simple SAP commands say.

PS: I saw a Python 3 version in the works? Are we getting near a release? Most modern Linux distros have completely abandoned Python 2.x, I'm having problems building the library these days.

Cheers all,

Marc

codeHorse87 commented 2 years ago

Hi @Marc-Girard without you having it mentioned specifically, I guess you're working on some kind of RPA use case? This is not really the focus or intention of PySAP. Aside of the different RPA toolings supporting automation via SAP GUI, I recommend going with a more specialized library such as https://github.com/gutskodv/PySapGUI or, as this library does, implement your use case with a library helping to manipulate Windows forms.

codeHorse87 commented 2 years ago

@martingalloar what's your viewpoint on this? Due to the fact, that SAP can implement changes to the DIAG protocol without notice, I'd consider an RPA approach based on Windows forms as a more robust approach ( If you want to use the term "robust" and RPA in one sentence 😄 )

Hi @Marc-Girard without you having it mentioned specifically, I guess you're working on some kind of RPA use case? This is not really the focus or intention of PySAP. Aside of the different RPA toolings supporting automation via SAP GUI, I recommend going with a more specialized library such as https://github.com/gutskodv/PySapGUI or, as this library does, implement your use case with a library helping to manipulate Windows forms.

Marc-Girard commented 2 years ago

Hi @Marc-Girard without you having it mentioned specifically, I guess you're working on some kind of RPA use case? This is not really the focus or intention of PySAP. Aside of the different RPA toolings supporting automation via SAP GUI, I recommend going with a more specialized library such as https://github.com/gutskodv/PySapGUI or, as this library does, implement your use case with a library helping to manipulate Windows forms.

Thanks for the fast answer. I'm using Linux and OpenShift (K8S) to automate our SAP transactions. I figured out a way of running SAP GUI JAVA within a container image and automate it all via PyAutoGUI. It's an all open-source solution and works very well. Still, I think it'd be even better if I could simply address my SAP servers via the DIAG/RFC protocols. This might not be achievable, I was just wondering if I could head this way in the future.

martingalloar commented 2 years ago

Hey all! This is an interesting use case, but I tend to agree with what @codeHorse87 said, I don't think it fits with the main goal of pysap.

  1. Interacting with the SAP server to do things a little bit more of just basic stuff involves not only having an almost complete implementation of DIAG and the RFC protocols (and it's "embedded" variant), but also mimicking a good amount of client-side logic that's built into the SAP GUI client.
  2. The protocols are proprietary and undocumented, so highly subject to changes that will require continuously playing catchup on every release.
  3. Maybe the more "stable" protocol is going to be RFC, that while it's not documented at least have an SDK that can be looked at, but even though not sure if that's enough to fulfil some of the RPA use cases.

I think that going the UI automation path is probably a less painful and less expensive avenue to achieve your goals.

PS: Yes, I made some initial efforts to do the Python 3 port but hopefully this is something I can take back sooner.

codeHorse87 commented 2 years ago

Hi @Marc-Girard, just emphasising and on top of @martingalloar comments: PySAP is the result of reverse engineering and research of the proprietary RFC and DIAG protocols. For production integration purposes, SAP provides maintained libraries for the RFC protocol (see https://support.sap.com/en/product/connectors.html).

codeHorse87 commented 2 years ago

question answered

Marc-Girard commented 2 years ago

Thank you guys for your answers, it is appreciated. :)