Coder Social home page Coder Social logo

ignatandrei / appsettingseditor Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 2.0 551 KB

app settings editor - powered by Roslyn

Home Page: https://ignatandrei.github.io/appSettingsEditor/

License: MIT License

C# 1.60% HTML 0.13% CSS 2.22% JavaScript 96.04% Batchfile 0.01%
generator csharp roslyn dotnet dotnet-core dotnetcore code-generation code-generator code-generators csharp-sourcegenerator

appsettingseditor's Introduction

appSettingsEditor

app settings editor - powered by Roslyn

What it does

Autogenerates controller API for appsettings.json

Optional, it has also an endpoint for a HTML GUI editor

This is how swagger looks :

And you can browse to /settingsUI to have this editor ( powered by https://github.com/json-editor/json-editor )

How to use

Add 2 NUGET references:

appSettingEditorAPI appSettingsEditor

For your convenience, please add to the csproj :

	
<ItemGroup>
    <PackageReference Include="appSettingsEditor" Version="2021.3.21.2300" />
    <PackageReference Include="appSettingsEditorAPI" Version="2021.3.21.2300" />
  	<CompilerVisibleItemMetadata Include="AdditionalFiles" MetadataName="generateAPI" />
    <AdditionalFiles Include="appsettings.json" generateAPI="true" >
    		<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
	</AdditionalFiles>
</ItemGroup>
<PropertyGroup>
	<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
	<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)Generated</CompilerGeneratedFilesOutputPath>
</PropertyGroup>

If you want to see a GUI for settings ( /settingsUI) , please do

app.UseEndpoints(endpoints =>
{
endpoints.MapControllers(); // add next line
endpoints.MapSettingsView <SettingsJson.appsettings>(Configuration);
});

If you want to handle security, add

public partial class appsettingsController : ControllerBase
{
//partial void BeforeGet(appsettings data)
//{

//}
//partial void BeforeSave(appsettings data, appsettings original)
//{

//}

}

Known problems and solving

I have a versioning API .

Add this to Startup.cs ,

public void ConfigureServices(IServiceCollection services)
services.AddApiVersioning(
it =>
{
    it.AssumeDefaultVersionWhenUnspecified = true;
    it.DefaultApiVersion = new ApiVersion(1,0);
}
);

I have another file name app_custom_settings.json, not appsettings.json

Make the modifications below: In the csproj

<ItemGroup>
    <PackageReference Include="appSettingsEditor" Version="2021.3.21.2300" />
    <PackageReference Include="appSettingsEditorAPI" Version="2021.3.21.2300" />
    <CompilerVisibleItemMetadata Include="AdditionalFiles" MetadataName="generateAPI" />
    <AdditionalFiles Include="app_custom_setting.json" generateAPI="true">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </AdditionalFiles>
  </ItemGroup>
  <PropertyGroup>
    <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
    <CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)Generated</CompilerGeneratedFilesOutputPath>
  </PropertyGroup>

In the startup.cs

appSettingsEditor.Extensions.MapSettingsView<app_custom_setting>(endpoints, Configuration,"app_custom_setting.json","/api/app_custom_setting");

I have multiple appsettings.json

This is not supported yet for the GUI. Please make an issue and describe your problem

appsettingseditor's People

Contributors

ignatandrei avatar imgbotapp avatar mend-bolt-for-github[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

appsettingseditor's Issues

CVE-2021-26701 (High) detected in system.text.encodings.web.5.0.0.nupkg

CVE-2021-26701 - High Severity Vulnerability

Vulnerable Library - system.text.encodings.web.5.0.0.nupkg

Provides types for encoding and escaping strings for use in JavaScript, HyperText Markup Language (H...

Library home page: https://api.nuget.org/packages/system.text.encodings.web.5.0.0.nupkg

Path to dependency file: /src/appSettingEditor/appSettingEditorAPI/appSettingsEditorAPI.csproj

Path to vulnerable library: /home/wss-scanner/.nuget/packages/system.text.encodings.web/5.0.0/system.text.encodings.web.5.0.0.nupkg

Dependency Hierarchy:

  • system.text.json.5.0.0.nupkg (Root Library)
    • โŒ system.text.encodings.web.5.0.0.nupkg (Vulnerable Library)

Found in HEAD commit: 1a93f8f234c932a3c4b2c0cee747a0ad49d7e9de

Found in base branch: main

Vulnerability Details

.NET Core Remote Code Execution Vulnerability This CVE ID is unique from CVE-2021-24112.

Publish Date: 2021-02-25

URL: CVE-2021-26701

CVSS 3 Score Details (9.8)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: High
    • Integrity Impact: High
    • Availability Impact: High

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Release Date: 2021-02-25

Fix Resolution: System.Text.Encodings.Web - 4.5.1,4.7.2,5.0.1


Step up your Open Source Security Game with Mend here

CVE-2021-3822 (High) detected in jsoneditor-9.2.0.js

CVE-2021-3822 - High Severity Vulnerability

Vulnerable Library - jsoneditor-9.2.0.js

A web-based tool to view, edit, format, and validate JSON

Library home page: https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/9.2.0/jsoneditor.js

Path to dependency file: /settingsUI/index.html

Path to vulnerable library: /settingsUI/jsoneditor.js,/settingsUI/jsoneditor.js

Dependency Hierarchy:

  • โŒ jsoneditor-9.2.0.js (Vulnerable Library)

Found in base branch: main

Vulnerability Details

jsoneditor is vulnerable to Inefficient Regular Expression Complexity

Publish Date: 2021-09-27

URL: CVE-2021-3822

CVSS 3 Score Details (7.5)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: None
    • Integrity Impact: None
    • Availability Impact: High

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Release Date: 2021-09-27

Fix Resolution: jsoneditor - v9.5.6


Step up your Open Source Security Game with Mend here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.