Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Finish v1.1-r22
Browse files Browse the repository at this point in the history
  • Loading branch information
ufna committed May 30, 2018
2 parents 51848c8 + 9011544 commit 0a94241
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Key features:

Check the [Wiki](https://hiazma.atlassian.net/wiki/display/VAR) for plugin usage examples and installation notes.

Current version: **1.1 R 21** (UE 4.18-4.19)
Current version: **1.1 R 22** (UE 4.18-4.19)

![SCREENSHOT](SCREENSHOT.jpg)

Expand Down
17 changes: 17 additions & 0 deletions Source/VaRestPlugin/Classes/VaRestSettings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2018 Vladimir Alyamkin. All Rights Reserved.

#pragma once

#include "VaRestSettings.generated.h"

UCLASS(config = Engine, defaultconfig)
class VARESTPLUGIN_API UVaRestSettings : public UObject
{
GENERATED_UCLASS_BODY()

public:
/** You can disable request content logging to avoid security vulnerability */
UPROPERTY(Config, EditAnywhere, Category = "VaRest")
bool bExtendedLog;

};
25 changes: 24 additions & 1 deletion Source/VaRestPlugin/Private/VaRestPlugin.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
// Copyright 2014 Vladimir Alyamkin. All Rights Reserved.

#include "VaRestPlugin.h"
#include "VaRestSettings.h"
#include "VaRestJsonObject.h"
#include "VaRestJsonValue.h"
#include "VaRestRequestJSON.h"
#include "VaRestPluginPrivatePCH.h"

//#include "UObject/Package.h"
//#include "Misc/ConfigCacheIni.h"

#include "Developer/Settings/Public/ISettingsModule.h"

#define LOCTEXT_NAMESPACE "VaRest"

class FVaRestPlugin : public IVaRestPlugin
{
/** IModuleInterface implementation */
Expand All @@ -15,14 +23,29 @@ class FVaRestPlugin : public IVaRestPlugin
UVaRestJsonObject::StaticClass();
UVaRestJsonValue::StaticClass();
UVaRestRequestJSON::StaticClass();

// Register settings
if (ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings"))
{
SettingsModule->RegisterSettings("Project", "Plugins", "VaRest",
LOCTEXT("RuntimeSettingsName", "VaRest Kit"),
LOCTEXT("RuntimeSettingsDescription", "Configure API keys for VaRest"),
GetMutableDefault<UVaRestSettings>()
);
}
}

virtual void ShutdownModule() override
{

if (ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings"))
{
SettingsModule->UnregisterSettings("Project", "Plugins", "VaRest");
}
}
};

IMPLEMENT_MODULE( FVaRestPlugin, VaRestPlugin )

DEFINE_LOG_CATEGORY(LogVaRest);

#undef LOCTEXT_NAMESPACE
35 changes: 31 additions & 4 deletions Source/VaRestPlugin/Private/VaRestRequestJSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "VaRestRequestJSON.h"
#include "VaRestJsonObject.h"
#include "VaRestLibrary.h"
#include "VaRestSettings.h"
#include "VaRestPluginPrivatePCH.h"

#include "CoreMisc.h"
Expand Down Expand Up @@ -278,6 +279,9 @@ void UVaRestRequestJSON::ExecuteProcessRequest()

void UVaRestRequestJSON::ProcessRequest()
{
// Cache default settings for extended logs
const UVaRestSettings* DefaultSettings = GetDefault<UVaRestSettings>();

// Set verb
switch (RequestVerb)
{
Expand Down Expand Up @@ -339,7 +343,15 @@ void UVaRestRequestJSON::ProcessRequest()
HttpRequest->SetContentAsString(StringRequestContent);
}

UE_LOG(LogVaRest, Log, TEXT("Request (urlencoded): %s %s %s"), *HttpRequest->GetVerb(), *HttpRequest->GetURL(), *UrlParams, *StringRequestContent);
// Check extended log to avoid security vulnerability (#133)
if (DefaultSettings->bExtendedLog)
{
UE_LOG(LogVaRest, Log, TEXT("%s: Request (urlencoded): %s %s %s %s"), *VA_FUNC_LINE, *HttpRequest->GetVerb(), *HttpRequest->GetURL(), *UrlParams, *StringRequestContent);
}
else
{
UE_LOG(LogVaRest, Log, TEXT("%s: Request (urlencoded): %s %s (check bExtendedLog for additional data)"), *VA_FUNC_LINE, *HttpRequest->GetVerb(), *HttpRequest->GetURL());
}

break;
}
Expand Down Expand Up @@ -368,7 +380,15 @@ void UVaRestRequestJSON::ProcessRequest()
// Apply params
HttpRequest->SetContentAsString(UrlParams);

UE_LOG(LogVaRest, Log, TEXT("Request (url body): %s %s %s"), *HttpRequest->GetVerb(), *HttpRequest->GetURL(), *UrlParams);
// Check extended log to avoid security vulnerability (#133)
if (DefaultSettings->bExtendedLog)
{
UE_LOG(LogVaRest, Log, TEXT("%s: Request (url body): %s %s %s"), *VA_FUNC_LINE, *HttpRequest->GetVerb(), *HttpRequest->GetURL(), *UrlParams);
}
else
{
UE_LOG(LogVaRest, Log, TEXT("%s: Request (url body): %s %s (check bExtendedLog for additional data)"), *VA_FUNC_LINE, *HttpRequest->GetVerb(), *HttpRequest->GetURL());
}

break;
}
Expand Down Expand Up @@ -526,8 +546,15 @@ bool UVaRestRequestJSON::HasTag(FName Tag) const

FString UVaRestRequestJSON::GetResponseContentAsString(bool bCacheResponseContent)
{
// Check we have valide response
if (!bIsValidJsonResponse || !ResponseJsonObj || !ResponseJsonObj->IsValidLowLevel())
// Check we have valid json response
if (!bIsValidJsonResponse)
{
// We've cached response content in OnProcessRequestComplete()
return ResponseContent;
}

// Check we have valid response object
if (!ResponseJsonObj || !ResponseJsonObj->IsValidLowLevel())
{
// Discard previous cached string if we had one
ResponseContent = DeprecatedResponseString;
Expand Down
9 changes: 9 additions & 0 deletions Source/VaRestPlugin/Private/VaRestSettings.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright 2018 Vladimir Alyamkin. All Rights Reserved.

#include "VaRestSettings.h"

UVaRestSettings::UVaRestSettings(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{

}
4 changes: 2 additions & 2 deletions VaRestPlugin.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"FileVersion" : 3,

"FriendlyName" : "VaRest",
"Version" : 21,
"VersionName" : "1.1-r21",
"Version" : 22,
"VersionName" : "1.1-r22",
"CreatedBy" : "Vladimir Alyamkin",
"CreatedByURL" : "http://alyamkin.com",
"EngineVersion" : "4.19.0",
Expand Down

0 comments on commit 0a94241

Please sign in to comment.