Skip to content

Commit d32f9b6

Browse files
committed
url uniqueness hash generation
1 parent f56f5bd commit d32f9b6

9 files changed

Lines changed: 354 additions & 321 deletions

dojo/db_migrations/0259_locations.py

Lines changed: 240 additions & 244 deletions
Large diffs are not rendered by default.

dojo/fixtures/defect_dojo_sample_data_locations.json

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46122,7 +46122,8 @@
4612246122
"path": "",
4612346123
"query": "",
4612446124
"fragment": "",
46125-
"host_validation_failure": false
46125+
"host_validation_failure": false,
46126+
"hash": "03009c0636425af566fb6b737db82852812fe2969107ef299530a248f78c4761"
4612646127
}
4612746128
},
4612846129
{
@@ -46137,7 +46138,8 @@
4613746138
"path": "",
4613846139
"query": "",
4613946140
"fragment": "",
46140-
"host_validation_failure": false
46141+
"host_validation_failure": false,
46142+
"hash": "f1ef169262638cbeabd36e60b021936c5a925beda67b52bd1b52847aa10352e1"
4614146143
}
4614246144
},
4614346145
{
@@ -46152,7 +46154,8 @@
4615246154
"path": "",
4615346155
"query": "",
4615446156
"fragment": "",
46155-
"host_validation_failure": false
46157+
"host_validation_failure": false,
46158+
"hash": "025d6b16f8cfba2d8e15e85deb81963a84d5dd3c700614f8e8fda87378cf58aa"
4615646159
}
4615746160
},
4615846161
{
@@ -46167,7 +46170,8 @@
4616746170
"path": "",
4616846171
"query": "",
4616946172
"fragment": "",
46170-
"host_validation_failure": false
46173+
"host_validation_failure": false,
46174+
"hash": "0f93015b731ab1bc5ea1332a90781a2045d46e70ec1090361f68db58265a3271"
4617146175
}
4617246176
},
4617346177
{
@@ -46182,7 +46186,8 @@
4618246186
"path": "bodgeit/",
4618346187
"query": "",
4618446188
"fragment": "",
46185-
"host_validation_failure": false
46189+
"host_validation_failure": false,
46190+
"hash": "94405be03445dd80d4e542775bf5797252cd907ecfeb381b51f72b5f01c78e4b"
4618646191
}
4618746192
},
4618846193
{
@@ -46197,7 +46202,8 @@
4619746202
"path": "bodgeit/about.jsp",
4619846203
"query": "",
4619946204
"fragment": "",
46200-
"host_validation_failure": false
46205+
"host_validation_failure": false,
46206+
"hash": "96e8eda7ebef554ead75dd22b2b6408b19498648964075d0cd8babf16bcddea9"
4620146207
}
4620246208
},
4620346209
{
@@ -46212,7 +46218,8 @@
4621246218
"path": "bodgeit/admin.jsp",
4621346219
"query": "",
4621446220
"fragment": "",
46215-
"host_validation_failure": false
46221+
"host_validation_failure": false,
46222+
"hash": "9eac0b36d89ea41c3ca850519bdf071471991f565dc1f5c0a3385a856a2817af"
4621646223
}
4621746224
},
4621846225
{
@@ -46227,7 +46234,8 @@
4622746234
"path": "bodgeit/advanced.jsp",
4622846235
"query": "",
4622946236
"fragment": "",
46230-
"host_validation_failure": false
46237+
"host_validation_failure": false,
46238+
"hash": "b1550d532705cf9e2441cf2d42e143f21d9991b1eb964aa88e52159eb1c5ff31"
4623146239
}
4623246240
},
4623346241
{
@@ -46242,7 +46250,8 @@
4624246250
"path": "bodgeit/basket.jsp",
4624346251
"query": "",
4624446252
"fragment": "",
46245-
"host_validation_failure": false
46253+
"host_validation_failure": false,
46254+
"hash": "efaf0a94394a5a2e117454956d67a1c43f95da40b7d7d5c158b049eded4cbe07"
4624646255
}
4624746256
},
4624846257
{
@@ -46257,7 +46266,8 @@
4625746266
"path": "bodgeit/contact.jsp",
4625846267
"query": "",
4625946268
"fragment": "",
46260-
"host_validation_failure": false
46269+
"host_validation_failure": false,
46270+
"hash": "7c00a6008791144f8e587507469ba1aaf5858a497a5fd2fd4fa5c29e942c4004"
4626146271
}
4626246272
},
4626346273
{
@@ -46272,7 +46282,8 @@
4627246282
"path": "bodgeit/home.jsp",
4627346283
"query": "",
4627446284
"fragment": "",
46275-
"host_validation_failure": false
46285+
"host_validation_failure": false,
46286+
"hash": "317895cd12da9908f97ebe8e63cb6395fed39d14925b631d9d4c1362b6458c20"
4627646287
}
4627746288
},
4627846289
{
@@ -46287,7 +46298,8 @@
4628746298
"path": "bodgeit/login.jsp",
4628846299
"query": "",
4628946300
"fragment": "",
46290-
"host_validation_failure": false
46301+
"host_validation_failure": false,
46302+
"hash": "2850f6a08fa0bd443f200525cc170231ce867d810fce483a0e3867f2b8807bfb"
4629146303
}
4629246304
},
4629346305
{
@@ -46302,7 +46314,8 @@
4630246314
"path": "bodgeit/logout.jsp",
4630346315
"query": "",
4630446316
"fragment": "",
46305-
"host_validation_failure": false
46317+
"host_validation_failure": false,
46318+
"hash": "c77e801a98a44ae86442c03f8dc2c068a3ce72d745c69aa290cce2c91c5be802"
4630646319
}
4630746320
},
4630846321
{
@@ -46317,7 +46330,8 @@
4631746330
"path": "bodgeit/password.jsp",
4631846331
"query": "",
4631946332
"fragment": "",
46320-
"host_validation_failure": false
46333+
"host_validation_failure": false,
46334+
"hash": "0710d27be344e66a9b1554d493f1e14f6b060dacba8ab64b5d2f86f49b85cca2"
4632146335
}
4632246336
},
4632346337
{
@@ -46332,7 +46346,8 @@
4633246346
"path": "bodgeit/product.jsp",
4633346347
"query": "",
4633446348
"fragment": "",
46335-
"host_validation_failure": false
46349+
"host_validation_failure": false,
46350+
"hash": "95f7dc925856be6f19bcfcc4b5c542d8a382815709900d6ab91693e3864bf75e"
4633646351
}
4633746352
},
4633846353
{
@@ -46347,7 +46362,8 @@
4634746362
"path": "bodgeit/register.jsp",
4634846363
"query": "",
4634946364
"fragment": "",
46350-
"host_validation_failure": false
46365+
"host_validation_failure": false,
46366+
"hash": "fddeec108eaec6a43060f43a44e228740350710cb3c4475ddd7cc7da7f740206"
4635146367
}
4635246368
},
4635346369
{
@@ -46362,7 +46378,8 @@
4636246378
"path": "bodgeit/score.jsp",
4636346379
"query": "",
4636446380
"fragment": "",
46365-
"host_validation_failure": false
46381+
"host_validation_failure": false,
46382+
"hash": "312cfc49152f6445cdb53df02fc65c966accd3e90e709fbe63bce73703085708"
4636646383
}
4636746384
},
4636846385
{
@@ -46377,7 +46394,8 @@
4637746394
"path": "bodgeit/search.jsp",
4637846395
"query": "",
4637946396
"fragment": "",
46380-
"host_validation_failure": false
46397+
"host_validation_failure": false,
46398+
"hash": "cac8b9e23292f238ae36c2c98600c1e3c813f48a53b6f8ec4f3accb0dda42886"
4638146399
}
4638246400
},
4638346401
{
@@ -46392,7 +46410,8 @@
4639246410
"path": "endpoint/420/edit/",
4639346411
"query": "",
4639446412
"fragment": "",
46395-
"host_validation_failure": false
46413+
"host_validation_failure": false,
46414+
"hash": "f28d3752e452cde3e00a3aaf885fe153037ae69d9726e6a0936ee7da3225c1ad"
4639646415
}
4639746416
},
4639846417
{

dojo/fixtures/dojo_testdata_locations.json

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,8 @@
805805
"host": "127.0.0.1",
806806
"query": "",
807807
"path": "endpoint/420/edit/",
808-
"port": 80
808+
"port": 80,
809+
"hash": "f28d3752e452cde3e00a3aaf885fe153037ae69d9726e6a0936ee7da3225c1ad"
809810
}
810811
},
811812
{
@@ -818,7 +819,8 @@
818819
"host": "localhost",
819820
"query": "",
820821
"path": "",
821-
"port": 21
822+
"port": 21,
823+
"hash": "025d6b16f8cfba2d8e15e85deb81963a84d5dd3c700614f8e8fda87378cf58aa"
822824
}
823825
},
824826
{
@@ -831,7 +833,8 @@
831833
"host": "127.0.0.1",
832834
"query": "",
833835
"path": "",
834-
"port": 22
836+
"port": 22,
837+
"hash": "03009c0636425af566fb6b737db82852812fe2969107ef299530a248f78c4761"
835838
}
836839
},
837840
{
@@ -844,7 +847,8 @@
844847
"host": "foo.bar",
845848
"query": "",
846849
"path": "",
847-
"port": 21
850+
"port": 21,
851+
"hash": "3c82808602507ea78a48dc605d86476f5cc609f99d446d1a9c9539d5c7c10166"
848852
}
849853
},
850854
{
@@ -857,7 +861,8 @@
857861
"host": "foo.bar",
858862
"query": "",
859863
"path": "",
860-
"port": 80
864+
"port": 80,
865+
"hash": "c1f60206ce7dac6202baec6f6251006e499113356869f605d0168f13e1d593ac"
861866
}
862867
},
863868
{
@@ -870,7 +875,8 @@
870875
"host": "bar.foo",
871876
"query": "",
872877
"path": "",
873-
"port": 80
878+
"port": 80,
879+
"hash": "99e0dbdf63598bfa7c3310a6785638117134c44ac59a38785e9e81fece0878da"
874880
}
875881
},
876882
{
@@ -883,7 +889,8 @@
883889
"host": "bar.foo",
884890
"query": "",
885891
"path": "",
886-
"port": 443
892+
"port": 443,
893+
"hash": "26259e2d4e77789a856808509ba2d9a50838bdc76d71f596a1bb346bbcb30332"
887894
}
888895
},
889896
{
@@ -896,7 +903,8 @@
896903
"host": "bar.foo",
897904
"query": "",
898905
"path": "f6",
899-
"port": 443
906+
"port": 443,
907+
"hash": "4e5614106ea6ca9c15c3328731036b06ab32c45fb2ed013601350748e2d3ed85"
900908
}
901909
},
902910
{

dojo/location/utils.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,7 @@
1313
def save_location(unsaved_location: AbstractLocation) -> AbstractLocation:
1414
# Only support URLs at this time
1515
if isinstance(unsaved_location, URL):
16-
return URL.objects.get_or_create(
17-
protocol=unsaved_location.protocol,
18-
user_info=unsaved_location.user_info,
19-
host=unsaved_location.host,
20-
port=unsaved_location.port,
21-
path=unsaved_location.path,
22-
query=unsaved_location.query,
23-
fragment=unsaved_location.fragment,
24-
host_validation_failure=unsaved_location.host_validation_failure,
25-
)[0]
16+
return URL.get_or_create_from_object(unsaved_location)
2617
error_message = f"Unsupported location type {type(unsaved_location)}"
2718
raise ValidationError(error_message)
2819

0 commit comments

Comments
 (0)