New: Secure URLs for Links and Services (#3219)

pull/2/head
Qstick 6 years ago committed by Leonardo Galli
parent 969ef5c515
commit cbdea30a6e

@ -2,23 +2,18 @@ using NzbDrone.Common.Http;
namespace NzbDrone.Common.Cloud
{
public interface ISonarrCloudRequestBuilder
public interface IRadarrCloudRequestBuilder
{
IHttpRequestBuilderFactory Services { get; }
IHttpRequestBuilderFactory SkyHookTvdb { get; }
IHttpRequestBuilderFactory TMDB { get; }
IHttpRequestBuilderFactory TMDBSingle { get; }
}
public class SonarrCloudRequestBuilder : ISonarrCloudRequestBuilder
public class RadarrCloudRequestBuilder : IRadarrCloudRequestBuilder
{
public SonarrCloudRequestBuilder()
public RadarrCloudRequestBuilder()
{
Services = new HttpRequestBuilder("http://radarr.aeonlucid.com/v1/")
.CreateFactory();
SkyHookTvdb = new HttpRequestBuilder("http://skyhook.sonarr.tv/v1/tvdb/{route}/{language}/")
.SetSegment("language", "en")
Services = new HttpRequestBuilder("https://radarr.aeonlucid.com/v1/")
.CreateFactory();
TMDB = new HttpRequestBuilder("https://api.themoviedb.org/3/{route}/{id}{secondaryRoute}")
@ -31,7 +26,6 @@ namespace NzbDrone.Common.Cloud
}
public IHttpRequestBuilderFactory Services { get; private set; }
public IHttpRequestBuilderFactory SkyHookTvdb { get; private set; }
public IHttpRequestBuilderFactory TMDB { get; private set; }
public IHttpRequestBuilderFactory TMDBSingle { get; private set; }
}

@ -81,7 +81,7 @@
<Compile Include="Cache\CachedDictionary.cs" />
<Compile Include="Cache\ICached.cs" />
<Compile Include="Cache\ICachedDictionary.cs" />
<Compile Include="Cloud\SonarrCloudRequestBuilder.cs" />
<Compile Include="Cloud\RadarrCloudRequestBuilder.cs" />
<Compile Include="Composition\Container.cs" />
<Compile Include="Composition\ContainerBuilderBase.cs" />
<Compile Include="Composition\IContainer.cs" />

@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.Framework
Mocker.SetConstant<CurlHttpDispatcher>(new CurlHttpDispatcher(Mocker.Resolve<IHttpProxySettingsProvider>(), Mocker.Resolve<NLog.Logger>()));
Mocker.SetConstant<IHttpProvider>(new HttpProvider(TestLogger));
Mocker.SetConstant<IHttpClient>(new HttpClient(new IHttpRequestInterceptor[0], Mocker.Resolve<CacheManager>(), Mocker.Resolve<RateLimitService>(), Mocker.Resolve<FallbackHttpDispatcher>(), TestLogger));
Mocker.SetConstant<ISonarrCloudRequestBuilder>(new SonarrCloudRequestBuilder());
Mocker.SetConstant<IRadarrCloudRequestBuilder>(new RadarrCloudRequestBuilder());
}
//Used for tests that rely on parsing working correctly.

@ -16,7 +16,7 @@ namespace NzbDrone.Core.HealthCheck.Checks
private readonly IHttpRequestBuilderFactory _cloudRequestBuilder;
public ProxyCheck(ISonarrCloudRequestBuilder cloudRequestBuilder, IConfigService configService, IHttpClient client, Logger logger)
public ProxyCheck(IRadarrCloudRequestBuilder cloudRequestBuilder, IConfigService configService, IHttpClient client, Logger logger)
{
_configService = configService;
_client = client;

@ -28,8 +28,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
{
private readonly IHttpClient _httpClient;
private readonly Logger _logger;
private readonly IHttpRequestBuilderFactory _requestBuilder;
private readonly IHttpRequestBuilderFactory _movieBuilder;
private readonly ITmdbConfigService _configService;
private readonly IMovieService _movieService;
@ -38,13 +37,10 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
private readonly IAlternativeTitleService _altTitleService;
private readonly IRadarrAPIClient _radarrAPI;
private readonly IHttpRequestBuilderFactory _apiBuilder;
public SkyHookProxy(IHttpClient httpClient, ISonarrCloudRequestBuilder requestBuilder, ITmdbConfigService configService, IMovieService movieService,
public SkyHookProxy(IHttpClient httpClient, IRadarrCloudRequestBuilder requestBuilder, ITmdbConfigService configService, IMovieService movieService,
IPreDBService predbService, IImportExclusionsService exclusionService, IAlternativeTitleService altTitleService, IRadarrAPIClient radarrAPI, Logger logger)
{
_httpClient = httpClient;
_requestBuilder = requestBuilder.SkyHookTvdb;
_movieBuilder = requestBuilder.TMDB;
_configService = configService;
_movieService = movieService;

@ -21,7 +21,7 @@ namespace NzbDrone.Core.MetadataSource
private readonly IHttpClient _httpClient;
private readonly IHttpRequestBuilderFactory _tmdbBuilder;
public TmdbConfigService(ICacheManager cacheManager, IHttpClient httpClient, ISonarrCloudRequestBuilder requestBuilder)
public TmdbConfigService(ICacheManager cacheManager, IHttpClient httpClient, IRadarrCloudRequestBuilder requestBuilder)
{
_configurationCache = cacheManager.GetCache<ConfigResource>(GetType(), "configuration_cache");
_httpClient = httpClient;

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using NLog;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
@ -30,7 +30,7 @@ namespace NzbDrone.Core.NetImport.RSSImport
EnableAuto = true,
ProfileId = 1,
Implementation = GetType().Name,
Settings = new RSSImportSettings { Link = "http://rss.imdb.com/list/YOURLISTID" },
Settings = new RSSImportSettings { Link = "https://rss.imdb.com/list/YOURLISTID" },
};
yield return new NetImportDefinition
{
@ -39,7 +39,7 @@ namespace NzbDrone.Core.NetImport.RSSImport
EnableAuto = true,
ProfileId = 1,
Implementation = GetType().Name,
Settings = new RSSImportSettings { Link = "http://rss.imdb.com/user/IMDBUSERID/watchlist" },
Settings = new RSSImportSettings { Link = "https://rss.imdb.com/user/IMDBUSERID/watchlist" },
};
}

@ -1,4 +1,4 @@
using FluentValidation;
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
@ -19,7 +19,7 @@ namespace NzbDrone.Core.NetImport.RSSImport
public RSSImportSettings()
{
Link = "http://rss.yoursite.com";
Link = "https://rss.yoursite.com";
}
[FieldDefinition(0, Label = "RSS Link", HelpText = "Link to the rss feed of movies.")]

@ -30,7 +30,7 @@ namespace NzbDrone.Core.Notifications
private string GetMessage(Movie movie, QualityModel quality)
{
var qualityString = quality.Quality.ToString();
var ImdbUrl = "http://www.imdb.com/title/" + movie.ImdbId + "/";
var ImdbUrl = "https://www.imdb.com/title/" + movie.ImdbId + "/";
if (quality.Revision.Version > 1)
{

@ -17,7 +17,7 @@ namespace NzbDrone.Core.Update
private readonly IHttpClient _httpClient;
private readonly IHttpRequestBuilderFactory _requestBuilder;
public UpdatePackageProvider(IHttpClient httpClient, ISonarrCloudRequestBuilder requestBuilder)
public UpdatePackageProvider(IHttpClient httpClient, IRadarrCloudRequestBuilder requestBuilder)
{
_httpClient = httpClient;
_requestBuilder = requestBuilder.Services;

@ -103,15 +103,15 @@ Handlebars.registerHelper('remotePoster', function() {
});
Handlebars.registerHelper('traktUrl', function() {
return 'http://trakt.tv/search/tmdb/' + this.tmdbId + '?id_type=movie';
return 'https://trakt.tv/search/tmdb/' + this.tmdbId + '?id_type=movie';
});
Handlebars.registerHelper('imdbUrl', function() {
return 'http://imdb.com/title/' + this.imdbId;
return 'https://imdb.com/title/' + this.imdbId;
});
Handlebars.registerHelper('tvdbUrl', function() {
return 'http://imdb.com/title/tt' + this.imdbId;
return 'https://imdb.com/title/tt' + this.imdbId;
});
Handlebars.registerHelper('tmdbUrl', function() {

Loading…
Cancel
Save