From 6ee1e09671f3c663bf4918a724cb0e585d7bd2cc Mon Sep 17 00:00:00 2001 From: Trevi Awater Date: Thu, 21 Nov 2024 10:51:46 +0100 Subject: [PATCH] Install gitleaks --- .gitleaks.toml | 13 +++++ .pre-commit-config.yaml | 6 +++ .../Resources/Resource.designer.cs | 1 - .../Xamarin.Neo4j.Tests/QueryHelperTests.cs | 51 +++++++++++++++---- .../Xamarin.Neo4j.iOS.csproj | 12 ++--- 5 files changed, 66 insertions(+), 17 deletions(-) create mode 100644 .gitleaks.toml create mode 100644 .pre-commit-config.yaml diff --git a/.gitleaks.toml b/.gitleaks.toml new file mode 100644 index 0000000..f0c754d --- /dev/null +++ b/.gitleaks.toml @@ -0,0 +1,13 @@ +title = "Gitleaks Configuration" + +[[rules]] +id = "generic-api-key" # Add a unique ID for the rule +description = "Generic API Key" +regex = '''(?i)(api_key|apikey|auth_token|access_token|secret)[:=]["']?[a-z0-9]{32,}''' +tags = ["apikey", "secret"] + +[allowlist] +paths = [ + ".env", # Matches .env file in any directory + ".gitignore" # Matches .gitignore file +] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..447b46d --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,6 @@ +repos: + - repo: https://github.com/gitleaks/gitleaks + rev: v8.19.0 + hooks: + - id: gitleaks + args: ["--config=.gitleaks.toml"] diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.Android/Resources/Resource.designer.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.Android/Resources/Resource.designer.cs index ce2cad1..5fc10bb 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.Android/Resources/Resource.designer.cs +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.Android/Resources/Resource.designer.cs @@ -2,7 +2,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.Tests/QueryHelperTests.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.Tests/QueryHelperTests.cs index bc822ad..c7f2edd 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.Tests/QueryHelperTests.cs +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.Tests/QueryHelperTests.cs @@ -6,7 +6,7 @@ namespace Xamarin.Neo4j.Tests public class QueryHelperTests { [Test] - public void TestWithUnlabeledRelationship() + public void ConvertsQueryWithUnlabeledRelationshipToAddDisplayVariable() { const string query = "MATCH (t:Tender)-[]->(z) RETURN t, z"; const string expected = "MATCH (t:Tender)-[display_variable_1]->(z) RETURN display_variable_1, t, z"; @@ -17,7 +17,7 @@ namespace Xamarin.Neo4j.Tests } [Test] - public void TestWithLabeledWithoutAliasRelationship() + public void ConvertsLabeledRelationshipWithoutAliasToAddDisplayVariable() { const string query = "MATCH (t:Tender)-[:LAST]->(z) RETURN t, z"; const string expected = "MATCH (t:Tender)-[display_variable_1:LAST]->(z) RETURN display_variable_1, t, z"; @@ -28,7 +28,7 @@ namespace Xamarin.Neo4j.Tests } [Test] - public void TestWithLabeledAndAliasedRelationship() + public void LeavesLabeledAndAliasedRelationshipQueryUnchanged() { const string query = "MATCH (t:Tender)-[y:LAST]->(z) RETURN t, z, y"; var expected = query; @@ -39,7 +39,7 @@ namespace Xamarin.Neo4j.Tests } [Test] - public void TestWithLabeledAndAliasedReturnAll() + public void ConvertsLabeledRelationshipWithReturnAllToAddDisplayVariable() { const string query = "MATCH (t:Tender)-[:LAST]->(z) RETURN *"; const string expected = "MATCH (t:Tender)-[display_variable_1:LAST]->(z) RETURN *"; @@ -50,7 +50,7 @@ namespace Xamarin.Neo4j.Tests } [Test] - public void TestWithUnlabeledReturnAll() + public void ConvertsUnlabeledRelationshipWithReturnAllToAddDisplayVariable() { const string query = "MATCH (t:Tender)-[]->(z) RETURN *"; const string expected = "MATCH (t:Tender)-[display_variable_1]->(z) RETURN *"; @@ -61,7 +61,7 @@ namespace Xamarin.Neo4j.Tests } [Test] - public void TestWithLabeledAndAliasedReturnAllWithMultipleRelationships() + public void ConvertsMultipleLabeledRelationshipsWithReturnAllToAddDisplayVariables() { const string query = "MATCH (t:Tender)-[:LAST]->(z)-[:NEXT]->(x) RETURN *"; const string expected = "MATCH (t:Tender)-[display_variable_1:LAST]->(z)-[display_variable_2:NEXT]->(x) RETURN *"; @@ -72,7 +72,7 @@ namespace Xamarin.Neo4j.Tests } [Test] - public void TestWithNoReturn() + public void LeavesQueryWithNoReturnClauseUnchanged() { const string query = "MATCH (t:Tender)-[:LAST]->(z)"; var expected = query; @@ -83,7 +83,7 @@ namespace Xamarin.Neo4j.Tests } [Test] - public void TestWithMultipleUnlabeledRelationships() + public void ConvertsMultipleUnlabeledRelationshipsToAddDisplayVariables() { const string query = "MATCH (t:Tender)-[]->(z)-[]->(x) RETURN t, z, x"; const string expected = @@ -95,7 +95,7 @@ namespace Xamarin.Neo4j.Tests } [Test] - public void TestBackwardsDirection() + public void ConvertsBackwardsRelationshipToAddDisplayVariable() { const string query = "MATCH (tv:TenderVersion)<-[:HAS_VERSION]-(t:Tender) RETURN tv, t"; const string expected = @@ -107,7 +107,7 @@ namespace Xamarin.Neo4j.Tests } [Test] - public void TestWithMultipleLabeledRelationships() + public void ConvertsMultipleLabeledRelationshipsToAddDisplayVariables() { const string query = "MATCH (t:Tender)-[:LAST]->(z)-[:NEXT]->(x) RETURN t, z, x"; const string expected = @@ -118,6 +118,37 @@ namespace Xamarin.Neo4j.Tests Assert.AreEqual(expected, actual); } + [Test] + public void LeavesQueryWithMultipleLabeledRelationshipsAndReturnAllWithAliasUnchanged() + { + const string query = "MATCH (t:Tender)-[y:LAST]->(z)-[x:NEXT]->(x) RETURN *"; + var expected = query; + + var actual = QueryHelper.ToDisplayQuery(query); + + Assert.AreEqual(expected, actual); + } + [Test] + public void LeavesComplexQueryWithMultipleRelationshipsAndAliasesUnchanged() + { + const string query = "MATCH (t:Tender)-[y:LAST]->(z)-[x:NEXT]->(x)-[]->(y) RETURN *"; + const string expected = "MATCH (t:Tender)-[y:LAST]->(z)-[x:NEXT]->(x)-[display_variable_1]->(y) RETURN *"; + + var actual = QueryHelper.ToDisplayQuery(query); + + Assert.AreEqual(expected, actual); + } + + [Test] + public void AdjustsComplexQueryWithLimitToAddDisplayVariable() + { + const string query = "MATCH (t:Tender)-[y:LAST]->(z)-[x:NEXT]->(x)-[]->(y) RETURN * LIMIT 10"; + const string expected = "MATCH (t:Tender)-[y:LAST]->(z)-[x:NEXT]->(x)-[display_variable_1]->(y) RETURN * LIMIT 10"; + + var actual = QueryHelper.ToDisplayQuery(query); + + Assert.AreEqual(expected, actual); + } } } diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Xamarin.Neo4j.iOS.csproj b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Xamarin.Neo4j.iOS.csproj index 368e7c2..67d179f 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Xamarin.Neo4j.iOS.csproj +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Xamarin.Neo4j.iOS.csproj @@ -138,12 +138,6 @@ - - - {756232D0-DBB0-4AEB-B1CF-1F5CA12CAC85} - Xamarin.Neo4j - - @@ -154,5 +148,11 @@ + + + {756232d0-dbb0-4aeb-b1cf-1f5ca12cac85} + Xamarin.Neo4j + + \ No newline at end of file