Init WFuzz state

This commit is contained in:
Jan Stárek
2019-10-09 13:24:01 +02:00
parent 7c3ed5ef0b
commit a5eb2a97e1
114 changed files with 6221 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Parser\Parser.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.OpenApi.Models;
using Models;
using Newtonsoft.Json;
using Parser;
namespace OpenApiParserCLI
{
static class Program
{
static int Main(string[] args)
{
if (args.Length != 2)
{
Console.WriteLine("Bad arguments provided.");
PrintHelp();
return 1;
}
string openApiDocFilePath = args[0];
string outputEndpointsFilePath = args[1];
if (!ValidateArguments(openApiDocFilePath, outputEndpointsFilePath))
{
PrintHelp();
return 1;
}
OpenApiDocument openApiDocument = OpenApiDocumentParser.ParseOpenApiDocument(openApiDocFilePath);
List<Endpoint> endpoints = EndpointParser.ParseAllEndpoints(openApiDocument);
string json = JsonConvert.SerializeObject(endpoints, Formatting.Indented);
File.WriteAllText(outputEndpointsFilePath, json);
return 0;
}
static bool ValidateArguments(string openApiDocFilePath, string outputEndpointsFilePath)
{
if (!File.Exists(openApiDocFilePath))
{
Console.WriteLine("Cannot find specified OpenApi file");
return false;
}
try
{
File.Create(outputEndpointsFilePath).Close();
}
catch
{
Console.WriteLine("Cannot create output file on defined path.");
return false;
}
return true;
}
static void PrintHelp()
{
Console.WriteLine("Arguments:");
Console.WriteLine("1] OpenAPI doc. file");
Console.WriteLine("2] Output file with JSON endpoints specification");
Console.WriteLine("Example: parser.exe api.yaml output.json");
}
}
}