Example #1
0
        /// <summary>
        /// Checks whether <paramref name="zapProcess"/>'s version is equal or higher than the minimum required version for this API client.
        /// </summary>
        /// <param name="zapProcess"></param>
        /// <returns></returns>
        public static bool CheckIfMinimumZapVersion(IZapProcess zapProcess)
        {
            var core    = new CoreComponent(zapProcess);
            var version = core.GetVersion();

            if (version.StartsWith("D-"))
            {
                return(version.CompareTo(MinimumZapDailyVersion) >= 0);
            }
            else
            {
                return(new Version(version) >= new Version(MinimumZapVersion));
            }
        }
Example #2
0
        /// <summary>
        /// Initiates a new instance of the <see cref="ZapApi"/> class and registers the default components.
        /// </summary>
        /// <param name="zapProcess">The ZAP process to connect to.</param>
        public ZapApi(IZapProcess zapProcess)
        {
            _zapProcess           = zapProcess;
            _registeredComponents = new Dictionary <Type, ComponentBase>();

            RegisterComponent(new ActiveScannerComponent(zapProcess));
            RegisterComponent(new AntiCsrfComponent(zapProcess));
            RegisterComponent(new AuthenticationComponent(zapProcess));
            RegisterComponent(new AuthorizationComponent(zapProcess));
            RegisterComponent(new AutoUpdateComponent(zapProcess));
            RegisterComponent(new CoreComponent(zapProcess));
            RegisterComponent(new ForcedUserComponent(zapProcess));
            RegisterComponent(new GlobalExcludeUrlComponent(zapProcess));
            RegisterComponent(new HttpSessionsComponent(zapProcess));
            RegisterComponent(new ParamsComponent(zapProcess));
            RegisterComponent(new PassiveScannerComponent(zapProcess));
            RegisterComponent(new RevealComponent(zapProcess));
            RegisterComponent(new ScriptComponent(zapProcess));
            RegisterComponent(new SearchComponent(zapProcess));
            RegisterComponent(new UsersComponent(zapProcess));
        }
Example #3
0
        public HttpClient(IZapProcess zapProcess)
        {
            var uriBuilder = new UriBuilder("http", zapProcess.Host, zapProcess.Port, "proxy.pac");

            _webProxy = new WebProxy(uriBuilder.Uri);
        }
Example #4
0
 /// <summary>
 /// Initiates a new instance of the <see cref="GlobalExcludeUrlComponent"/> class.
 /// </summary>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public GlobalExcludeUrlComponent(IZapProcess zapProcess)
     : this(null, zapProcess)
 {
 }
 /// <summary>
 /// Initiates a new instance of the <see cref="ContextComponent"/> class.
 /// </summary>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public ContextComponent(IZapProcess zapProcess)
     : this(null, zapProcess)
 {
 }
 /// <summary>
 /// Initiates a new instance of the <see cref="ForcedUserComponent"/> class.
 /// </summary>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public ForcedUserComponent(IZapProcess zapProcess)
     : this(null, zapProcess)
 {
 }
Example #7
0
 /// <summary>
 /// Initiates a new instance of the <see cref="AntiCsrfComponent"/> class with a specific HTTP client implementation.
 /// </summary>
 /// <param name="httpClient">The HTTP client implementation.</param>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public AntiCsrfComponent(IHttpClient httpClient, IZapProcess zapProcess)
     : base(httpClient, zapProcess, "acsrf")
 {
 }
Example #8
0
 /// <summary>
 /// Initiates a new instance of the <see cref="PassiveScannerComponent"/> class with a specific HTTP client implementation.
 /// </summary>
 /// <param name="httpClient">The HTTP client implementation.</param>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public PassiveScannerComponent(IHttpClient httpClient, IZapProcess zapProcess)
     : base(httpClient, zapProcess, "pscan")
 {
 }
 /// <summary>
 /// Initiates a new instance of the <see cref="HttpSessionsComponent"/> class with a specific HTTP client implementation.
 /// </summary>
 /// <param name="httpClient">The HTTP client implementation.</param>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public HttpSessionsComponent(IHttpClient httpClient, IZapProcess zapProcess)
     : base(httpClient, zapProcess, "httpSessions")
 {
 }
 /// <summary>
 /// Initiates a new instance of the <see cref="SessionManagementComponent"/> class with a specific HTTP client implementation.
 /// </summary>
 /// <param name="httpClient">The HTTP client implementation.</param>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public SessionManagementComponent(IHttpClient httpClient, IZapProcess zapProcess)
     : base(httpClient, zapProcess, "sessionManagement")
 {
 }
 /// <summary>
 /// Initiates a new instance of the <see cref="SessionManagementComponent"/> class.
 /// </summary>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public SessionManagementComponent(IZapProcess zapProcess)
     : this(null, zapProcess)
 {
 }
 public ComponentBaseStub(IHttpClient httpClient, IZapProcess zapProcess)
     : base(httpClient, zapProcess, "ascan")
 {
 }
 /// <summary>
 /// Initiates a new instance of the <see cref="ParamsComponent"/> class with a specific HTTP client implementation.
 /// </summary>
 /// <param name="httpClient">The HTTP client implementation.</param>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public ParamsComponent(IHttpClient httpClient, IZapProcess zapProcess)
     : base(httpClient, zapProcess, "params")
 {
 }
 /// <summary>
 /// Initiates a new instance of the <see cref="ParamsComponent"/> class.
 /// </summary>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public ParamsComponent(IZapProcess zapProcess)
     : this(null, zapProcess)
 {
 }
 /// <summary>
 /// Initiates a new instance of the <see cref="AutoUpdateComponent"/> class with a specific HTTP client implementation.
 /// </summary>
 /// <param name="httpClient">The HTTP client implementation.</param>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public AutoUpdateComponent(IHttpClient httpClient, IZapProcess zapProcess)
     : base(httpClient, zapProcess, "autoupdate")
 {
 }
Example #16
0
 /// <summary>
 /// Initiates a new instance of the <see cref="SpiderComponent"/> class.
 /// </summary>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public SpiderComponent(IZapProcess zapProcess)
     : this(null, zapProcess)
 { }
 /// <summary>
 /// Initiates a new instance of the <see cref="HttpSessionsComponent"/> class.
 /// </summary>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public HttpSessionsComponent(IZapProcess zapProcess)
     : this(null, zapProcess)
 {
 }
Example #18
0
 /// <summary>
 /// Initiates a new instance of the <see cref="SpiderComponent"/> class with a specific HTTP client implementation.
 /// </summary>
 /// <param name="httpClient">The HTTP client implementation.</param>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public SpiderComponent(IHttpClient httpClient, IZapProcess zapProcess)
     : base(httpClient, zapProcess, "spider")
 { }
Example #19
0
 /// <summary>
 /// Initiates a new instance of the <see cref="PassiveScannerComponent"/> class.
 /// </summary>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public PassiveScannerComponent(IZapProcess zapProcess)
     : this(null, zapProcess)
 {
 }
 /// <summary>
 /// Initiates a new instance of the <see cref="RevealComponent"/> class.
 /// </summary>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public RevealComponent(IZapProcess zapProcess)
     : this(null, zapProcess)
 {
 }
Example #21
0
 /// <summary>
 /// Initiates a new instance of the <see cref="AntiCsrfComponent"/> class.
 /// </summary>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public AntiCsrfComponent(IZapProcess zapProcess)
     : this(null, zapProcess)
 {
 }
 /// <summary>
 /// Initiates a new instance of the <see cref="RevealComponent"/> class with a specific HTTP client implementation.
 /// </summary>
 /// <param name="httpClient">The HTTP client implementation.</param>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public RevealComponent(IHttpClient httpClient, IZapProcess zapProcess)
     : base(httpClient, zapProcess, "reveal")
 {
 }
Example #23
0
 /// <summary>
 /// Initiates a new instance of the <see cref="ComponentBase"/> class.
 /// </summary>
 /// <param name="httpClient">The HTTP client implementation.</param>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 /// <param name="componentUrlName">The API name of the implementing component.</param>
 protected ComponentBase(IHttpClient httpClient, IZapProcess zapProcess, string componentUrlName)
 {
     _httpClient   = httpClient ?? new HttpClient(zapProcess);
     _zapProcess   = zapProcess;
     ComponentName = componentUrlName;
 }
 /// <summary>
 /// Initiates a new instance of the <see cref="AuthenticationComponent"/> class.
 /// </summary>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public AuthenticationComponent(IZapProcess zapProcess)
     : this(null, zapProcess)
 {
 }
 /// <summary>
 /// Initiates a new instance of the <see cref="ForcedUserComponent"/> class with a specific HTTP client implementation.
 /// </summary>
 /// <param name="httpClient">The HTTP client implementation.</param>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public ForcedUserComponent(IHttpClient httpClient, IZapProcess zapProcess)
     : base(httpClient, zapProcess, "forcedUser")
 {
 }
 /// <summary>
 /// Initiates a new instance of the <see cref="AuthenticationComponent"/> class with a specific HTTP client implementation.
 /// </summary>
 /// <param name="httpClient">The HTTP client implementation.</param>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public AuthenticationComponent(IHttpClient httpClient, IZapProcess zapProcess)
     : base(httpClient, zapProcess, "authentication")
 {
 }
 /// <summary>
 /// Initiates a new instance of the <see cref="ContextComponent"/> class with a specific HTTP client implementation.
 /// </summary>
 /// <param name="httpClient">The HTTP client implementation.</param>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public ContextComponent(IHttpClient httpClient, IZapProcess zapProcess)
     : base(httpClient, zapProcess, "context")
 {
 }
 /// <summary>
 /// Initiates a new instance of the <see cref="AutoUpdateComponent"/> class.
 /// </summary>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public AutoUpdateComponent(IZapProcess zapProcess)
     : this(null, zapProcess)
 {
 }
Example #29
0
 /// <summary>
 /// Initiates a new instance of the <see cref="GlobalExcludeUrlComponent"/> class with a specific HTTP client implementation.
 /// </summary>
 /// <param name="httpClient">The HTTP client implementation.</param>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public GlobalExcludeUrlComponent(IHttpClient httpClient, IZapProcess zapProcess)
     : base(httpClient, zapProcess, "globalexcludeurl")
 {
 }
 /// <summary>
 /// Initiates a new instance of the <see cref="UsersComponent"/> class with a specific HTTP client implementation.
 /// </summary>
 /// <param name="httpClient">The HTTP client implementation.</param>
 /// <param name="zapProcess">The ZAP process to connect to.</param>
 public UsersComponent(IHttpClient httpClient, IZapProcess zapProcess)
     : base(httpClient, zapProcess, "users")
 { }