netfishers-onl / Netshot

Network Configuration and Compliance Management
http://www.netfishers.onl/netshot
249 stars 60 forks source link

[Python] Unable to use the module ciscoconfparse with the latest version of NS #303

Closed lyesbenhouhou closed 8 months ago

lyesbenhouhou commented 8 months ago

Hi, Does anyone succeeded to run a Python script with importing the module “ciscoconfparse” in the latest version of Netshot 0.19.3 ? After a tshoot, I found that there’s a missing function called “gethostbyname_ex” in the module “socket”… I found this issue (https://github.com/oracle/graalpython/issues/331) in graalpy that was fixed with the latest version 24.0.0 but I don’t know how to upgrade the embedded version in Graalvm…(No update available for python) If someone can help :)

Bellow the error I've in the Netshot's log:

2024-04-01 16:43:55,821 ERROR [grizzly-http-server-5] PythonRule: Error while running the script on device 2125. org.graalvm.polyglot.PolyglotException: ModuleNotFoundError: No module named 'ciscoconfparse' at org.graalvm.sdk/org.graalvm.polyglot.Context.eval(Context.java:403) at onl.netfishers.netshot.compliance.rules.PythonRule.check(PythonRule.java:279) at onl.netfishers.netshot.rest.RestService.testRule(RestService.java:4941) at jdk.internal.reflect.GeneratedMethodAccessor884.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:146) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:189) at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:219) at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:93) at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:478) at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:400) at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:81) at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:256) at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248) at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244) at org.glassfish.jersey.internal.Errors.process(Errors.java:292) at org.glassfish.jersey.internal.Errors.process(Errors.java:274) at org.glassfish.jersey.internal.Errors.process(Errors.java:244) at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265) at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:235) at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:684) at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394) at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:358) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:311) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205) at org.glassfish.grizzly.servlet.FilterChainImpl.doFilter(FilterChainImpl.java:124) at org.glassfish.grizzly.servlet.FilterChainImpl.invokeFilterChain(FilterChainImpl.java:83) at org.glassfish.grizzly.servlet.ServletHandler.doServletService(ServletHandler.java:202) at org.glassfish.grizzly.servlet.ServletHandler.service(ServletHandler.java:149) at org.glassfish.grizzly.http.server.HttpHandler$1.run(HttpHandler.java:200) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549) at java.base/java.lang.Thread.run(Thread.java:833)

SCadilhac commented 8 months ago

Have you tried this? https://github.com/SCadilhac/ciscoconfparse

(Next version of Netshot will use JDK 21 with up-to-date Polyglot components)

lyesbenhouhou commented 8 months ago

Sylvain, you rock ! I've no more the issue of DNS resolver with your ciscoconfparse and my scripts works well. Merci :)

SCadilhac commented 8 months ago

My pleasure @lyesbenhouhou ;-)