From cbdea30a6e9708918728e409edd0ac6c3140daba Mon Sep 17 00:00:00 2001 From: Qstick Date: Fri, 7 Dec 2018 05:21:43 -0500 Subject: [PATCH] New: Secure URLs for Links and Services (#3219) --- ...uestBuilder.cs => RadarrCloudRequestBuilder.cs} | 14 ++++---------- src/NzbDrone.Common/NzbDrone.Common.csproj | 2 +- src/NzbDrone.Core.Test/Framework/CoreTest.cs | 2 +- src/NzbDrone.Core/HealthCheck/Checks/ProxyCheck.cs | 2 +- .../MetadataSource/SkyHook/SkyHookProxy.cs | 8 ++------ .../MetadataSource/TmdbConfigurationService.cs | 2 +- src/NzbDrone.Core/NetImport/RSSImport/RSSImport.cs | 6 +++--- .../NetImport/RSSImport/RSSImportSettings.cs | 4 ++-- .../Notifications/NotificationService.cs | 2 +- src/NzbDrone.Core/Update/UpdatePackageProvider.cs | 2 +- src/UI/Handlebars/Helpers/Movie.js | 6 +++--- 11 files changed, 20 insertions(+), 30 deletions(-) rename src/NzbDrone.Common/Cloud/{SonarrCloudRequestBuilder.cs => RadarrCloudRequestBuilder.cs} (63%) diff --git a/src/NzbDrone.Common/Cloud/SonarrCloudRequestBuilder.cs b/src/NzbDrone.Common/Cloud/RadarrCloudRequestBuilder.cs similarity index 63% rename from src/NzbDrone.Common/Cloud/SonarrCloudRequestBuilder.cs rename to src/NzbDrone.Common/Cloud/RadarrCloudRequestBuilder.cs index 8e6b55e11..da368e0e0 100644 --- a/src/NzbDrone.Common/Cloud/SonarrCloudRequestBuilder.cs +++ b/src/NzbDrone.Common/Cloud/RadarrCloudRequestBuilder.cs @@ -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; } } diff --git a/src/NzbDrone.Common/NzbDrone.Common.csproj b/src/NzbDrone.Common/NzbDrone.Common.csproj index a3897d393..3e7204007 100644 --- a/src/NzbDrone.Common/NzbDrone.Common.csproj +++ b/src/NzbDrone.Common/NzbDrone.Common.csproj @@ -81,7 +81,7 @@ - + diff --git a/src/NzbDrone.Core.Test/Framework/CoreTest.cs b/src/NzbDrone.Core.Test/Framework/CoreTest.cs index 144e519fc..dd9221b02 100644 --- a/src/NzbDrone.Core.Test/Framework/CoreTest.cs +++ b/src/NzbDrone.Core.Test/Framework/CoreTest.cs @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test.Framework Mocker.SetConstant(new CurlHttpDispatcher(Mocker.Resolve(), Mocker.Resolve())); Mocker.SetConstant(new HttpProvider(TestLogger)); Mocker.SetConstant(new HttpClient(new IHttpRequestInterceptor[0], Mocker.Resolve(), Mocker.Resolve(), Mocker.Resolve(), TestLogger)); - Mocker.SetConstant(new SonarrCloudRequestBuilder()); + Mocker.SetConstant(new RadarrCloudRequestBuilder()); } //Used for tests that rely on parsing working correctly. diff --git a/src/NzbDrone.Core/HealthCheck/Checks/ProxyCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/ProxyCheck.cs index 1732c549e..bca6c7aa6 100644 --- a/src/NzbDrone.Core/HealthCheck/Checks/ProxyCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/Checks/ProxyCheck.cs @@ -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; diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index a7f78458a..89df9fc5c 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -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; diff --git a/src/NzbDrone.Core/MetadataSource/TmdbConfigurationService.cs b/src/NzbDrone.Core/MetadataSource/TmdbConfigurationService.cs index 7c0d39cb5..2f5185d42 100644 --- a/src/NzbDrone.Core/MetadataSource/TmdbConfigurationService.cs +++ b/src/NzbDrone.Core/MetadataSource/TmdbConfigurationService.cs @@ -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(GetType(), "configuration_cache"); _httpClient = httpClient; diff --git a/src/NzbDrone.Core/NetImport/RSSImport/RSSImport.cs b/src/NzbDrone.Core/NetImport/RSSImport/RSSImport.cs index f64a8c5fa..3b0bf9682 100644 --- a/src/NzbDrone.Core/NetImport/RSSImport/RSSImport.cs +++ b/src/NzbDrone.Core/NetImport/RSSImport/RSSImport.cs @@ -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" }, }; } diff --git a/src/NzbDrone.Core/NetImport/RSSImport/RSSImportSettings.cs b/src/NzbDrone.Core/NetImport/RSSImport/RSSImportSettings.cs index 254b144fc..f02b55344 100644 --- a/src/NzbDrone.Core/NetImport/RSSImport/RSSImportSettings.cs +++ b/src/NzbDrone.Core/NetImport/RSSImport/RSSImportSettings.cs @@ -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.")] diff --git a/src/NzbDrone.Core/Notifications/NotificationService.cs b/src/NzbDrone.Core/Notifications/NotificationService.cs index 1a36e375f..91b323715 100644 --- a/src/NzbDrone.Core/Notifications/NotificationService.cs +++ b/src/NzbDrone.Core/Notifications/NotificationService.cs @@ -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) { diff --git a/src/NzbDrone.Core/Update/UpdatePackageProvider.cs b/src/NzbDrone.Core/Update/UpdatePackageProvider.cs index 5abb55726..96959e5af 100644 --- a/src/NzbDrone.Core/Update/UpdatePackageProvider.cs +++ b/src/NzbDrone.Core/Update/UpdatePackageProvider.cs @@ -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; diff --git a/src/UI/Handlebars/Helpers/Movie.js b/src/UI/Handlebars/Helpers/Movie.js index 66f6fee85..ad9ba82ad 100644 --- a/src/UI/Handlebars/Helpers/Movie.js +++ b/src/UI/Handlebars/Helpers/Movie.js @@ -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() {