📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
fixed an issue when origins and ip blacklist could not be reset
Blue Mousefa55905afc58
diff --git a/apps/production/src/project/project.controller.ts b/apps/production/src/project/project.controller.tsindex cba4d358a..d63550c7c 100644--- a/apps/production/src/project/project.controller.ts+++ b/apps/production/src/project/project.controller.ts@@ -1746,10 +1746,14 @@ export class ProjectController {if (projectDTO.origins) {project.origins = _map(projectDTO.origins, _trim)+ } else {+ project.origins = []}if (projectDTO.ipBlacklist) {project.ipBlacklist = _map(projectDTO.ipBlacklist, _trim)+ } else {+ project.ipBlacklist = null}if (projectDTO.name) {diff --git a/apps/selfhosted/src/common/constants.ts b/apps/selfhosted/src/common/constants.tsindex 5077a9a61..5690541a7 100644--- a/apps/selfhosted/src/common/constants.ts+++ b/apps/selfhosted/src/common/constants.ts@@ -64,7 +64,7 @@ const DEFAULT_SELFHOSTED_UUID = 'deadbeef-dead-beef-dead-beefdeadbeef'const SELFHOSTED_UUID = getSelfhostedUUID()const ORIGINS_REGEX =- /^(?=.{1,255}$)[0-9A-Za-z:](?:(?:[0-9A-Za-z:]|-){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z:](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/+ /^(?=.{1,255}$)([0-9A-Za-z*:](?:(?:[0-9A-Za-z*:]|-){0,61}[0-9A-Za-z*:])?(?:\.[0-9A-Za-z*:](?:(?:[0-9A-Za-z*-]|-){0,61}[0-9A-Za-z*:])?)*)?$/const IP_REGEX =/^(([12]?[0-9]{1,2}|2[0-4][0-9]|25[0-5])(\.|\/)){4}([1-2]?[0-9]|3[0-2])$/const PID_REGEX = /^(?!.*--)[a-zA-Z0-9-]{12}$/diff --git a/apps/selfhosted/src/project/project.controller.ts b/apps/selfhosted/src/project/project.controller.tsindex 2f30cbbde..747251b3f 100644--- a/apps/selfhosted/src/project/project.controller.ts+++ b/apps/selfhosted/src/project/project.controller.ts@@ -475,10 +475,14 @@ export class ProjectController {if (projectDTO.origins) {project.origins = _map(projectDTO.origins, _trim)+ } else {+ project.origins = []}if (projectDTO.ipBlacklist) {project.ipBlacklist = _map(projectDTO.ipBlacklist, _trim)+ } else {+ project.ipBlacklist = []}if (projectDTO.name) {diff --git a/apps/selfhosted/src/project/project.service.ts b/apps/selfhosted/src/project/project.service.tsindex ed8c7504c..40ec72ed9 100644--- a/apps/selfhosted/src/project/project.service.ts+++ b/apps/selfhosted/src/project/project.service.ts@@ -312,40 +312,48 @@ export class ProjectService {return updFunnel}- validateProject(- projectDTO: ProjectDTO | UpdateProjectDto,- creatingProject = false,- ) {- if (_size(projectDTO.name) > 50)- throw new UnprocessableEntityException('The project name is too long')-- if (creatingProject) {- return- }-- if (!isValidPID(projectDTO.id))- throw new UnprocessableEntityException(- 'The provided Project ID (pid) is incorrect',- )+ validateOrigins(projectDTO: ProjectDTO | UpdateProjectDto) {if (_size(_join(projectDTO.origins, ',')) > 300)throw new UnprocessableEntityException('The list of allowed origins has to be smaller than 300 symbols',)- if (_size(_join(projectDTO.ipBlacklist, ',')) > 300)- throw new UnprocessableEntityException(- 'The list of allowed blacklisted IP addresses must be less than 300 characters.',- )_map(projectDTO.origins, host => {if (!ORIGINS_REGEX.test(_trim(host))) {throw new ConflictException(`Host ${host} is not correct`)}})+ }+ validateIPBlacklist(projectDTO: ProjectDTO | UpdateProjectDto) {+ if (_size(_join(projectDTO.ipBlacklist, ',')) > 300)+ throw new UnprocessableEntityException(+ 'The list of allowed blacklisted IP addresses must be less than 300 characters.',+ )_map(projectDTO.ipBlacklist, ip => {if (!net.isIP(_trim(ip)) && !IP_REGEX.test(_trim(ip))) {throw new ConflictException(`IP address ${ip} is not correct`)}})}++ validateProject(+ projectDTO: ProjectDTO | UpdateProjectDto,+ creatingProject = false,+ ) {+ if (_size(projectDTO.name) > 50)+ throw new UnprocessableEntityException('The project name is too long')++ if (creatingProject) {+ return+ }++ if (projectDTO?.id && !isValidPID(projectDTO.id))+ throw new UnprocessableEntityException(+ 'The provided Project ID (pid) is incorrect',+ )++ this.validateOrigins(projectDTO)+ this.validateIPBlacklist(projectDTO)+ }}