![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
github.com/gmaschi/log-exp-eval
The current implementation of the logical expression evaluator assumes that:
;x AND y
;docker compose
commands throughout the application to docker-compose
.Run make server
to spin the database and server. The server runs at port 8080.
To stop the application and clean all resources, run make server-down
.
There are three commands to run the application tests:
make unit-test
: runs only unit tests;make integration-test
: runs only integration tests;make test
: runs both unit and integration tests.Integration tests will run in their own containers.
The full API documentation can be seen through the swagger document at internal/docs/generated/swagger.json
. You can also run directly from the application by running make swag-serve
. It will install go-swagger
through brew if you don't have it.
There is also a postman collection at internal/docs/postman/exp-eval-postman-collection.json
for convenience with all the main requests.
There are some important mentions regarding the challenge's requirements that need to be made:
v1
prefix was used to version the endpoints, so, the endpoint /evaluate/{expression_id}?x=1,y=0,z=1
described in the requirements is at v1/evaluate/{expression_id}?x=1,y=0,z=1
. This rule applies to every endpoint;v1/expressions
to perform both depending on the payload, we leverage the HTTP methods to differentiate between these two actions. POST
to create and PATCH
to update and expression.v1/expressions/{id}
: get expression by ID;v1/expressions/{id}
: delete expression by ID;v1/expressions
: updates an existing expression.The API requires authentication for all endpoints. There are two mocked bearer tokens that can be used to run requests against the server:
token 1: 74edf612f393b4eb01fbc2c29dd96671
token 2: d88b4b1e77c70ba780b56032db1c259b
Each token is tied to a specific user, and there are operations in the system that can only be performed by the author of the expression e.g.: updating/deleting/getting by id.
Request:
curl --location --request POST 'http://localhost:8080/v1/expressions' \
--header 'Authorization: Bearer 74edf612f393b4eb01fbc2c29dd96671' \
--header 'Content-Type: application/json' \
--data-raw '{
"expression": "((x OR y) AND (z OR k) OR j)"
}'
Response:
{
"expressionID": "659f9c60-9056-4ba2-ae12-bb70533d8671",
"expression": "((x OR y) AND (z OR k) OR j)",
"username": "John Doe",
"createdAt": "2023-02-05T18:03:59.41586Z",
"updatedAt": "2023-02-05T18:03:59.41586Z"
}
Request:
curl --location --request GET 'http://localhost:8080/v1/expressions/659f9c60-9056-4ba2-ae12-bb70533d8671' \
--header 'Authorization: Bearer 74edf612f393b4eb01fbc2c29dd96671'
Response:
{
"expressionID": "659f9c60-9056-4ba2-ae12-bb70533d8671",
"expression": "((x OR y) AND (z OR k) OR j)",
"username": "John Doe",
"createdAt": "2023-02-05T18:03:59.41586Z",
"updatedAt": "2023-02-05T18:03:59.41586Z"
}
List expressions endpoint was built with support for pagination by sending page_id
and page_size
as query parameters. PageID must be greater than 0. Pagination information (page number, page items and total number of pages will be added to the header response)
Request:
curl --location --request GET 'http://localhost:8080/v1/expressions?page_id=1&page_size=2' \
--header 'Authorization: Bearer 74edf612f393b4eb01fbc2c29dd96671'
Response:
[
{
"rowID": 1,
"expressionID": "659f9c60-9056-4ba2-ae12-bb70533d8671",
"expression": "((x OR y) AND (z OR k) OR j)",
"username": "John Doe",
"createdAt": "2023-02-05T18:03:59.41586Z",
"updatedAt": "2023-02-05T18:03:59.41586Z"
},
{
"rowID": 2,
"expressionID": "11625fa6-cb11-491d-97fa-089fa94d43b5",
"expression": "((x OR y) AND (z OR k) OR j)",
"username": "John Doe",
"createdAt": "2023-02-05T18:05:44.774641Z",
"updatedAt": "2023-02-05T18:05:44.774641Z"
}
]
Request:
curl --location --request DELETE 'http://localhost:8080/v1/expressions/11625fa6-cb11-491d-97fa-089fa94d43b5' \
--header 'Authorization: Bearer 74edf612f393b4eb01fbc2c29dd96671'
Response: A success response will return a 204 (status no content) http status.
Request:
curl --location --request GET 'http://localhost:8080/v1/evaluate/11625fa6-cb11-491d-97fa-089fa94d43b5?X=1&y=0&z=1&k=0&j=1' \
--header 'Authorization: Bearer 74edf612f393b4eb01fbc2c29dd96671' \
--header 'Content-Type: application/json' \
--data-raw '{
"expression": "((x OR y) AND (z OR k) OR j)"
}'
Response:
{
"result": true
}
The logical expression evaluator method used is not complete, leading to some misleading results for some edge cases. The following must still be implemented:
!
(NOT) operator;FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.