matecat / MateCat

MateCat is an AI driven translation tool for language industry professionals. Matecat makes machine translation post-editing and project outsourcing easy.
http://www.matecat.com
GNU Lesser General Public License v3.0
379 stars 176 forks source link

Filters and xliff params #3348

Closed mauretto78 closed 1 month ago

mauretto78 commented 4 months ago

WARNING - Removed PHP 5.6 compatibility. Language support 7.4+

ASANA https://app.asana.com/0/1134617950425092/1207299263774123

Xliff rules endpoints documentation

Schema

This endpoint returns the JSON schema used to validate QAModels:

GET /api/v3/xliff-config-template/schema

As you may notice the schema uses the Swagger naming conventions.

Create

Use this endpoint to create a template:

POST /api/v3/xliff-config-template/

Payload example:

{
  "name": "test",
  "rules": {
    "xliff12": [
      {
        "analysis": "new",
        "states": [
          "new",
          "translated",
          "needs-translation"
        ]
      },
      {
        "analysis": "pre-translated",
        "editor": "translated",
        "states": [
          "needs-review-adaptation",
          "needs-review-l10n"
        ],
        "match_category": "50_74"
      },
      {
        "analysis": "pre-translated",
        "editor": "approved",
        "states": [
          "x-ciao",
          "signed-off",
          "final"
        ]
      }
    ],
    "xliff20": [
      {
        "analysis": "new",
        "states": [
          "final",
          "x-pippo"
        ]
      }
    ]
  }
}

Response example:

{
  "id": 1,
  "uid": 1,
  "name": "test",
  "rules": {
    "xliff12": [
      {
        "states": [
          "new",
          "translated",
          "needs-translation"
        ],
        "analysis": "new"
      },
      {
        "states": [
          "needs-review-adaptation",
          "needs-review-l10n"
        ],
        "analysis": "pre-translated",
        "editor": "translated",
        "match_category": "50_74"
      },
      {
        "states": [
          "signed-off",
          "final"
        ],
        "analysis": "pre-translated",
        "editor": "approved",
        "match_category": "ice"
      }
    ],
    "xliff20": [
      {
        "states": [
          "final"
        ],
        "analysis": "new"
      }
    ]
  },
  "createdAt": "2024-07-29T17:18:05+02:00",
  "modifiedAt": "2024-08-08T15:44:45+02:00"
}

Modify

Use this endpoint to update an existing template:

PUT /api/v3/xliff-config-template/[:id]

Payload example:

{
    "name": "test",
    "rules": {
        "xliff12": [
            {
                "analysis": "new",
                "states": [
                    "new",
                    "translated",
                    "needs-translation"
                ]
            }
        ],
        "xliff20": [
            {
                "analysis": "new",
                "states": [
                    "final",
                    "x-pippo"
                ]
            }
        ]
    }
}

Response example:

{
    "id": 1,
    "uid": 1,
    "name": "test",
    "rules": {
        "xliff12": [
            {
                "states": [
                    "new",
                    "translated",
                    "needs-translation"
                ],
                "analysis": "new"
            }
        ],
        "xliff20": [
            {
                "states": [
                    "final"
                ],
                "analysis": "new"
            }
        ]
    },
    "createdAt": "2024-07-29T17:18:05+02:00",
    "modifiedAt": "2024-08-08T15:47:09+02:00"
}

Delete

Use this endpoint to delete an existing template:

DELETE /api/v3/xliff-config-template/[:id]

If no errors are thrown the endpoint will display the id of the new template:

{
    "id": 1
}

Fetch all

Use this endpoint to fetch all templates:

GET /api/v3/xliff-config-template/
{
    "current_page": 1,
    "per_page": 20,
    "last_page": 1,
    "total_count": 3,
    "prev": null,
    "next": null,
    "items": [
        {
            "id": 1,
            "uid": 1,
            "name": "test",
            "rules": {
                "xliff12": [
                    {
                        "states": [
                            "new"
                        ],
                        "analysis": "new",
                        "editor": "ignore-target-content"
                    }
                ],
                "xliff20": [
                    {
                        "states": [
                            "final"
                        ],
                        "analysis": "new",
                        "editor": "ignore-target-content"
                    }
                ]
            },
            "createdAt": "2024-05-31T16:49:41+02:00",
            "modifiedAt": "2024-05-31T17:16:56+02:00"
        },
        {
            "id": 2,
            "uid": 1,
            "name": "other test",
            "rules": {
                "xliff12": [
                    {
                        "states": [
                            "new"
                        ],
                        "analysis": "new",
                        "editor": "ignore-target-content"
                    }
                ],
                "xliff20": [
                    {
                        "states": [
                            "final"
                        ],
                        "analysis": "new",
                        "editor": "ignore-target-content"
                    }
                ]
            },
            "createdAt": "2024-05-31T16:57:59+02:00",
            "modifiedAt": "2024-05-31T17:09:03+02:00"
        }
    ]
}

Fetch single template

Use this endpoint to fetch a saved template:

GET /api/v3/xliff-config-template/[:id]

If the id does not belong to an existing model a 404 code will be return.

Response example:

{
    "id": 1,
    "uid": 1,
    "name": "test",
    "rules": {
        "xliff12": [
            {
                "states": [
                    "new"
                ],
                "analysis": "new",
                "editor": "ignore-target-content"
            }
        ],
        "xliff20": [
            {
                "states": [
                    "final"
                ],
                "analysis": "new",
                "editor": "ignore-target-content"
            }
        ]
    },
    "createdAt": "2024-05-31T16:49:41+02:00",
    "modifiedAt": "2024-05-31T17:16:53+02:00",
    "deletedAt": null
}

Filters params endpoints documentation

Schema

This endpoint returns the JSON schema used to validate QAModels:

GET /api/v3/filters-config-template/schema

As you may notice the schema uses the Swagger naming conventions.

Create

Use this endpoint to create a template:

POST /api/v3/filters-config-template/

Payload example:

{
  "name": "test",
  "json": {
       "extract_arrays": true,
       "translate_keys": ["pappa"]
    },
    "yaml": {
        "translate_keys": ["saas", "ddddd", "sss"]
    }
}

Response example:

{
  "id": 1,
  "uid": 1,
  "name": "test",
  "xml": [],
  "yaml": {
    "translate_keys": [
      "saas",
      "ddddd",
      "sss"
    ]
  },
  "json": {
    "extract_arrays": true,
    "translate_keys": [
      "pappa"
    ]
  },
  "ms_word": [],
  "ms_excel": [],
  "ms_powerpoint": [],
  "createdAt": "2024-08-12T17:57:56+02:00",
  "modifiedAt": null
}

Modify

Use this endpoint to update an existing template:

PUT /api/v3/filters-config-template/[:id]

Payload example:

{
  "name": "filters-template-modificato",
  "xml": {
    "preserve_whitespace": true,
    "translate_elements": [
      "ciao",
      "casa2"
    ],
    "translate_attributes": []
  },
  "json": {
    "extract_arrays": true,
    "translate_keys": [
      "pappa"
    ]
  },
  "yaml": {
    "translate_keys": [
      "saas",
      "ddddd",
      "sss"
    ]
  }
}

Response example:

{
  "id": 1,
  "uid": 1,
  "name": "filters-template-modificato",
  "xml": {
    "preserve_whitespace": true,
    "translate_elements": [
      "ciao",
      "casa2"
    ]
  },
  "yaml": {
    "translate_keys": [
      "saas",
      "ddddd",
      "sss"
    ]
  },
  "json": {
    "extract_arrays": true,
    "translate_keys": [
      "pappa"
    ]
  },
  "ms_word": [],
  "ms_excel": [],
  "ms_powerpoint": [],
  "createdAt": "2024-08-12T17:42:15+02:00",
  "modifiedAt": "2024-08-12T15:42:15+02:00"
}

Delete

Use this endpoint to delete an existing template:

DELETE /api/v3/filters-config-template/[:id]

If no errors are thrown the endpoint will display the id of the new template:

{
    "id": 1
}

Fetch all

Use this endpoint to fetch all templates:

GET /api/v3/filters-config-template/
{
  "current_page": 1,
  "per_page": 20,
  "last_page": 1,
  "total": 2,
  "prev": null,
  "next": null,
  "items": [
    {
      "id": 1,
      "uid": 1,
      "name": "filters-template-2",
      "xml": {
        "translate_elements": [
          "ciao",
          "casa"
        ]
      },
      "yaml": [],
      "json": [],
      "ms_word": [],
      "ms_excel": [],
      "ms_powerpoint": [],
      "createdAt": "2024-08-12T17:42:15+02:00",
      "modifiedAt": "2024-08-12T15:42:15+02:00"
    }
  ]
}

Fetch single template

Use this endpoint to fetch a saved template:

GET /api/v3/filters-config-template/[:id]

If the id does not belong to an existing model a 404 code will be return.

Response example:

{
  "id": 1,
  "uid": 1,
  "name": "filters-template-modificato",
  "xml": {
    "preserve_whitespace": true,
    "translate_elements": [
      "ciao",
      "casa2"
    ]
  },
  "yaml": {
    "translate_keys": [
      "saas",
      "ddddd",
      "sss"
    ]
  },
  "json": {
    "extract_arrays": true,
    "translate_keys": [
      "pappa"
    ]
  },
  "ms_word": [],
  "ms_excel": [],
  "ms_powerpoint": [],
  "createdAt": "2024-08-12T17:42:15+02:00",
  "modifiedAt": "2024-08-12T18:02:44+02:00"
}

Get values for the default template

Use this endpoint to fetch the default template:

GET /api/v3/filters-config-template/default
{
  "id": 0,
  "uid": 1,
  "name": "default",
  "xml": {
    "preserve_whitespace": false,
    "translate_elements": [],
    "do_not_translate_elements": [],
    "translate_attributes": []
  },
  "yaml": {
    "extract_arrays": false,
    "translate_keys": [],
    "do_not_translate_keys": []
  },
  "json": {
    "extract_arrays": false,
    "escape_forward_slashes": false,
    "translate_keys": [],
    "do_not_translate_keys": [],
    "context_keys": [],
    "character_limit": []
  },
  "ms_word": {
    "extract_doc_properties": false,
    "extract_comments": false,
    "extract_headers_footers": false,
    "extract_hidden_text": false,
    "accept_revisions": false,
    "exclude_styles": [],
    "exclude_highlight_colors": []
  },
  "ms_excel": {
    "extract_doc_properties": false,
    "extract_hidden_cells": false,
    "extract_diagrams": false,
    "extract_drawings": false,
    "extract_sheet_names": false,
    "exclude_columns": []
  },
  "ms_powerpoint": {
    "extract_doc_properties": false,
    "extract_hidden_slides": false,
    "extract_notes": true,
    "translate_slides": []
  },
  "created_at": "2024-08-12 19:41:16",
  "modified_at": "2024-08-12 19:41:16"
}

gitguardian[bot] commented 2 months ago

⚠️ GitGuardian has uncovered 15 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | | | -------------- | ------------------ | ------------------------------ | ---------------- | --------------- | -------------------- | | [630031](https://dashboard.gitguardian.com/workspace/110635/incidents/630031?occurrence=163769101) | Triggered | Generic Password | 85f44da1605a91d2d24bb3f7d2dd76289866e378 | tests/unit/JobDataStructTest.php | [View secret](https://github.com/matecat/MateCat/commit/85f44da1605a91d2d24bb3f7d2dd76289866e378#diff-dbd591dcc17f0680882da1a11dc165fc8f627a374b20695fbca39231a6446e40L33) | | [630031](https://dashboard.gitguardian.com/workspace/110635/incidents/630031?occurrence=163769102) | Triggered | Generic Password | 85f44da1605a91d2d24bb3f7d2dd76289866e378 | tests/unit/JobDataStructTest.php | [View secret](https://github.com/matecat/MateCat/commit/85f44da1605a91d2d24bb3f7d2dd76289866e378#diff-dbd591dcc17f0680882da1a11dc165fc8f627a374b20695fbca39231a6446e40R32) | | [630031](https://dashboard.gitguardian.com/workspace/110635/incidents/630031?occurrence=163769103) | Triggered | Generic Password | 6852bdfd0ec492c63426b675ef09996077cd8d9f | tests/unit/JobDataStructTest.php | [View secret](https://github.com/matecat/MateCat/commit/6852bdfd0ec492c63426b675ef09996077cd8d9f#diff-dbd591dcc17f0680882da1a11dc165fc8f627a374b20695fbca39231a6446e40L33) | | [630031](https://dashboard.gitguardian.com/workspace/110635/incidents/630031?occurrence=163769109) | Triggered | Generic Password | 6852bdfd0ec492c63426b675ef09996077cd8d9f | tests/unit/JobDataStructTest.php | [View secret](https://github.com/matecat/MateCat/commit/6852bdfd0ec492c63426b675ef09996077cd8d9f#diff-dbd591dcc17f0680882da1a11dc165fc8f627a374b20695fbca39231a6446e40R32) | | [630008](https://dashboard.gitguardian.com/workspace/110635/incidents/630008?occurrence=163769100) | Triggered | Generic Password | 85f44da1605a91d2d24bb3f7d2dd76289866e378 | tests/unit/DAO/TestJobDAO/DestroyCacheJobTest.php | [View secret](https://github.com/matecat/MateCat/commit/85f44da1605a91d2d24bb3f7d2dd76289866e378#diff-8c7b1ae632e8c2546287e665b778fc3eb82bf7ebd3d117779af4895b687776ddL47) | | [630008](https://dashboard.gitguardian.com/workspace/110635/incidents/630008?occurrence=163769104) | Triggered | Generic Password | 6852bdfd0ec492c63426b675ef09996077cd8d9f | tests/unit/DAO/TestJobDAO/DestroyCacheJobTest.php | [View secret](https://github.com/matecat/MateCat/commit/6852bdfd0ec492c63426b675ef09996077cd8d9f#diff-8c7b1ae632e8c2546287e665b778fc3eb82bf7ebd3d117779af4895b687776ddR45) | | [630008](https://dashboard.gitguardian.com/workspace/110635/incidents/630008?occurrence=163769105) | Triggered | Generic Password | 85f44da1605a91d2d24bb3f7d2dd76289866e378 | tests/unit/DAO/TestJobDAO/DestroyCacheJobTest.php | [View secret](https://github.com/matecat/MateCat/commit/85f44da1605a91d2d24bb3f7d2dd76289866e378#diff-8c7b1ae632e8c2546287e665b778fc3eb82bf7ebd3d117779af4895b687776ddR45) | | [630008](https://dashboard.gitguardian.com/workspace/110635/incidents/630008?occurrence=163769106) | Triggered | Generic Password | 6852bdfd0ec492c63426b675ef09996077cd8d9f | tests/unit/DAO/TestJobDAO/DestroyCacheJobTest.php | [View secret](https://github.com/matecat/MateCat/commit/6852bdfd0ec492c63426b675ef09996077cd8d9f#diff-8c7b1ae632e8c2546287e665b778fc3eb82bf7ebd3d117779af4895b687776ddL47) | | [630008](https://dashboard.gitguardian.com/workspace/110635/incidents/630008?occurrence=163769107) | Triggered | Generic Password | 6852bdfd0ec492c63426b675ef09996077cd8d9f | tests/unit/DAO/TestJobDAO/CreateFromStructJobTest.php | [View secret](https://github.com/matecat/MateCat/commit/6852bdfd0ec492c63426b675ef09996077cd8d9f#diff-91c94f95ab6e21ecac459cd5646302f4086af7a95e3ba1ed63d599c3fbc31e34L44) | | [630008](https://dashboard.gitguardian.com/workspace/110635/incidents/630008?occurrence=163769108) | Triggered | Generic Password | 85f44da1605a91d2d24bb3f7d2dd76289866e378 | tests/unit/DAO/TestJobDAO/CreateFromStructJobTest.php | [View secret](https://github.com/matecat/MateCat/commit/85f44da1605a91d2d24bb3f7d2dd76289866e378#diff-91c94f95ab6e21ecac459cd5646302f4086af7a95e3ba1ed63d599c3fbc31e34L44) | | [8740520](https://dashboard.gitguardian.com/workspace/110635/incidents/8740520?occurrence=128431936) | Triggered | Generic Password | 5e0f8cdd5d4696262d61db6f13a39af77b2d2673 | .htaccess | [View secret](https://github.com/matecat/MateCat/commit/5e0f8cdd5d4696262d61db6f13a39af77b2d2673#diff-270939b4fba4be968ab78e23dc0207eb893744491980a25c99a27c809a82ddabL47) | | [9120561](https://dashboard.gitguardian.com/workspace/110635/incidents/9120561?occurrence=143280747) | Triggered | Generic Password | 0f9e93d55b9816c4cb44f61e44fb4582f7021ec4 | public/js/cat_source/es6/components/projects/JobMenu.test.js | [View secret](https://github.com/matecat/MateCat/commit/0f9e93d55b9816c4cb44f61e44fb4582f7021ec4#diff-01adfd8883d31be5512ed1a3d3c5443b64892501d48ac2a3dd72b544d9436921L253) | | [9120561](https://dashboard.gitguardian.com/workspace/110635/incidents/9120561?occurrence=143280748) | Triggered | Generic Password | 0f9e93d55b9816c4cb44f61e44fb4582f7021ec4 | public/js/cat_source/es6/components/projects/JobMenu.test.js | [View secret](https://github.com/matecat/MateCat/commit/0f9e93d55b9816c4cb44f61e44fb4582f7021ec4#diff-01adfd8883d31be5512ed1a3d3c5443b64892501d48ac2a3dd72b544d9436921R250) | | [9120561](https://dashboard.gitguardian.com/workspace/110635/incidents/9120561?occurrence=143487697) | Triggered | Generic Password | 3b77e8995ab5955cb37fd94859ed52f43caf8f89 | public/js/cat_source/es6/components/projects/JobMenu.test.js | [View secret](https://github.com/matecat/MateCat/commit/3b77e8995ab5955cb37fd94859ed52f43caf8f89#diff-01adfd8883d31be5512ed1a3d3c5443b64892501d48ac2a3dd72b544d9436921R250) | | [9120561](https://dashboard.gitguardian.com/workspace/110635/incidents/9120561?occurrence=143487698) | Triggered | Generic Password | 3b77e8995ab5955cb37fd94859ed52f43caf8f89 | public/js/cat_source/es6/components/projects/JobMenu.test.js | [View secret](https://github.com/matecat/MateCat/commit/3b77e8995ab5955cb37fd94859ed52f43caf8f89#diff-01adfd8883d31be5512ed1a3d3c5443b64892501d48ac2a3dd72b544d9436921L253) |
🛠 Guidelines to remediate hardcoded secrets
1. Understand the implications of revoking this secret by investigating where it is used in your code. 2. Replace and store your secrets safely. [Learn here](https://blog.gitguardian.com/secrets-api-management?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) the best practices. 3. Revoke and [rotate these secrets](https://docs.gitguardian.com/secrets-detection/secrets-detection-engine/detectors/generics/generic_password#revoke-the-secret?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment). 4. If possible, [rewrite git history](https://blog.gitguardian.com/rewriting-git-history-cheatsheet?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment). Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data. To avoid such incidents in the future consider - following these [best practices](https://blog.gitguardian.com/secrets-api-management/?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) for managing and storing secrets including API keys and other credentials - install [secret detection on pre-commit](https://docs.gitguardian.com/ggshield-docs/integrations/git-hooks/pre-commit?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) to catch secret before it leaves your machine and ease remediation.

🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.